Method: MiGA::Cli::OptHelper#opt_filter_datasets
- Defined in:
- lib/miga/cli/opt_helper.rb
#opt_filter_datasets(opt, what = %i[ref multi active taxonomy])) ⇒ Object
Options to filter a list of datasets passed to OptionParser opt
, as determined by what
an Array with any combination of:
-
:ref To filter by reference (–ref) or query (–no-ref)
-
:multi To filter by multiple (–multi) or single (–no-multi) species
-
:active To filter by active (–active) or inactive (–no-active)
-
:taxonomy To filter by taxonomy (–taxonomy)
The “k-th” filter (–dataset-k) is always included
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/miga/cli/opt_helper.rb', line 126 def opt_filter_datasets(opt, what = %i[ref multi active taxonomy]) what.each do |w| case w when :ref opt.on( '--[no-]ref', 'Use only reference (or only non-reference) datasets' ) { |v| self[:ref] = v } when :multi opt.on( '--[no-]multi', 'Use only multi-species (or only single-species) datasets' ) { |v| self[:multi] = v } when :active opt.on( '--[no-]active', 'Use only active (or inactive) datasets' ) { |v| self[:active] = v } when :taxonomy opt.on( '-t', '--taxonomy RANK:TAXON', 'Filter by taxonomy' ) { |v| self[:taxonomy] = MiGA::Taxonomy.new(v) } else raise "Internal error: Unrecognized option: #{w}" end end opt.on( '--ds-list FILE', 'File containing a list of dataset names, one per line' ) { |v| self[:ds_list] = v } opt.on( '--dataset-k INTEGER', Integer, 'Use only the k-th dataset in the list' ) { |v| self[:dataset_k] = v } end |