Class: MiGA::Cli::Action::Find

Inherits:
MiGA::Cli::Action show all
Defined in:
lib/miga/cli/action/find.rb

Constant Summary

Constants included from MiGA

MiGA::CITATION, VERSION, VERSION_DATE, VERSION_NAME

Instance Attribute Summary

Attributes inherited from MiGA::Cli::Action

#cli

Attributes included from MiGA::Common::Net

#remote_connection_uri

Instance Method Summary collapse

Methods inherited from MiGA::Cli::Action

#complete, #empty_action, #initialize, #launch, load, #name

Methods inherited from MiGA

CITATION, CITATION_ARRAY, DEBUG, DEBUG_OFF, DEBUG_ON, DEBUG_TRACE_OFF, DEBUG_TRACE_ON, FULL_VERSION, LONG_VERSION, VERSION, VERSION_DATE, #advance, debug?, debug_trace?, initialized?, #like_io?, #num_suffix, rc_path, #result_files_exist?, #say

Methods included from MiGA::Common::Path

#root_path, #script_path

Methods included from MiGA::Common::Format

#clean_fasta_file, #seqs_length, #tabulate

Methods included from MiGA::Common::Net

#download_file_ftp, #http_request, #known_hosts, #main_server, #net_method, #normalize_encoding, #remote_connection

Methods included from MiGA::Common::SystemCall

#run_cmd, #run_cmd_opts

Constructor Details

This class inherits a constructor from MiGA::Cli::Action

Instance Method Details

#parse_cliObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/miga/cli/action/find.rb', line 7

def parse_cli
  cli.defaults = { add: false, ref: true }
  cli.parse do |opt|
    cli.opt_object(opt, [:project, :dataset_type])
    opt.on(
      '-a', '--add',
      'Register the datasets found',
      'By default, only lists them (dry run)'
    ) { |v| cli[:add] = v }
    opt.on(
      '-q', '--query',
      'Register datasets as query'
    ) { |v| cli[:ref] = !v }
    opt.on(
      '-u', '--user STRING',
      'Owner of the dataset.'
    ) { |v| cli[:user] = v }
    opt.on(
      '-m', '--metadata STRING',
      'Metadata as key-value pairs separated by = and delimited by comma',
      'Values are saved as strings except for booleans (true / false) or nil'
    ) { |v| cli[:metadata] = v }
  end
end

#performObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/miga/cli/action/find.rb', line 32

def perform
  p = cli.load_project
  ud = p.unregistered_datasets
  ud.each do |dn|
    cli.puts dn
    if cli[:add]
      cli.say "Registering: #{dn}"
      d = Dataset.new(p, dn, cli[:ref])
      (d)
      p.add_dataset(dn)
      res = d.first_preprocessing(true)
      cli.say "- #{res}"
    end
  end
end