Class: MiGA::Cli::Action::Ls
- Inherits:
-
MiGA::Cli::Action
- Object
- MiGA
- MiGA::Cli::Action
- MiGA::Cli::Action::Ls
- Defined in:
- lib/miga/cli/action/ls.rb
Constant Summary
Constants included from MiGA
MiGA::CITATION, VERSION, VERSION_DATE, VERSION_NAME
Instance Attribute Summary
Attributes inherited from MiGA::Cli::Action
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
Methods included from MiGA::Common::Format
#clean_fasta_file, #seqs_length, #tabulate
Methods included from MiGA::Common::Net
#download_file_ftp, #known_hosts, #remote_connection
Methods included from MiGA::Common::SystemCall
Constructor Details
This class inherits a constructor from MiGA::Cli::Action
Instance Method Details
#parse_cli ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/miga/cli/action/ls.rb', line 6 def parse_cli cli.defaults = { info: false, processing: false, silent: false } cli.parse do |opt| cli.opt_object(opt, [:project, :dataset_opt]) cli.opt_filter_datasets(opt) opt.on( '-i', '--info', 'Print additional information on each dataset' ) { |v| cli[:info] = v } opt.on( '-p', '--processing', 'Print information on processing advance' ) { |v| cli[:processing] = v } opt.on( '-t', '--task-status', 'Print the status of each processing step' ) { |v| cli[:taskstatus] = v } opt.on( '-m', '--metadata STRING', 'Print name and metadata field only', 'If set, ignores --info and forces --tab (without header)' ) { |v| cli[:datum] = v } opt.on( '-f', '--fields STR1,STR2,STR3', Array, 'Comma-delimited metadata fields to print' ) { |v| cli[:fields] = v } opt.on( '--tab', 'Return a tab-delimited table' ) { |v| cli[:tabular] = v } opt.on( '-o', '--output PATH', 'Create output file instead of returning to STDOUT' ) { |v| cli[:output] = v } opt.on( '-s', '--silent', 'No output and exit with non-zero status if the dataset list is empty' ) { |v| cli[:silent] = v } opt.on( '--exec CMD', 'Command to execute per dataset, with the following token variables:', '~ {{dataset}}: Name of the dataset', '~ {{project}}: Path to the project' ) { |v| cli[:exec] = v } end end |
#perform ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/miga/cli/action/ls.rb', line 53 def perform ds = cli.load_and_filter_datasets(cli[:silent]) p = cli.load_project exit(ds.empty? ? 1 : 0) if cli[:silent] head = nil fun = nil if cli[:datum] cli[:tabular] = true head = [nil, nil] fun = proc { |d| [d.name, d.[cli[:datum]]] } elsif cli[:fields] head = [:name] + cli[:fields] fun = proc { |d| [d.name] + cli[:fields].map { |f| d.[f] } } elsif cli[:info] head = Dataset.INFO_FIELDS fun = proc(&:info) elsif cli[:processing] head = [:name] + MiGA::Dataset.PREPROCESSING_TASKS fun = proc do |d| [d.name] + d.profile_advance.map { |i| %w[- done queued][i] } end elsif cli[:taskstatus] head = [:name] + MiGA::Dataset.PREPROCESSING_TASKS fun = proc { |d| [d.name] + d.results_status.values } else cli[:tabular] = true head = [nil] fun = proc { |d| [d.name] } end format_table(ds, head) do |d| if cli[:exec] MiGA::MiGA.run_cmd( cli[:exec].miga_variables(dataset: d.name, project: p.path) ) end fun[d] end end |