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, #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
Constructor Details
This class inherits a constructor from MiGA::Cli::Action
Instance Method Details
#parse_cli ⇒ Object
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 |
# File 'lib/miga/cli/action/ls.rb', line 7 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 } end end |
#perform ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/miga/cli/action/ls.rb', line 48 def perform ds = cli.load_and_filter_datasets(cli[:silent]) exit(ds.empty? ? 1 : 0) if cli[:silent] if !cli[:datum].nil? cli[:tabular] = true format_table(ds, [nil, nil]) { |d| [d.name, d.[cli[:datum]]] } elsif !cli[:fields].nil? format_table(ds, [:name] + cli[:fields]) do |d| [d.name] + cli[:fields].map { |f| d.[f] } end elsif cli[:info] format_table(ds, Dataset.INFO_FIELDS) { |d| d.info } elsif cli[:processing] comp = %w[- done queued] format_table(ds, [:name] + MiGA::Dataset.PREPROCESSING_TASKS) do |d| [d.name] + d.profile_advance.map { |i| comp[i] } end elsif cli[:taskstatus] format_table(ds, [:name] + MiGA::Dataset.PREPROCESSING_TASKS) do |d| [d.name] + d.results_status.values end else cli[:tabular] = true format_table(ds, [nil]) { |d| [d.name] } end end |