Skip to content

Commit

Permalink
Combine miga get params with --file
Browse files Browse the repository at this point in the history
Close #154
  • Loading branch information
lmrodriguezr committed Mar 20, 2024
1 parent 9e86d45 commit b43d9b1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 6 additions & 1 deletion lib/miga/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ class MiGA::Cli < MiGA::MiGA
attr_accessor :task

##
# The CLI parameters (except the task), and Array of String
# The unparsed CLI parameters (except the task), an Array of String
attr_accessor :argv

##
# The original ARGV passed to the CLI, an Array of String
attr_accessor :original_argv

##
# Action to launch, an object inheriting from MiGA::Cli::Action
attr_accessor :action
Expand Down Expand Up @@ -62,6 +66,7 @@ def initialize(argv)
@data = {}
@defaults = { verbose: false, tabular: false }
@opt_common = true
@original_argv = argv.dup
@objects = {}
if argv[0].nil? or argv[0].to_s[0] == '-'
@task = :generic
Expand Down
8 changes: 6 additions & 2 deletions lib/miga/cli/action/get.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def parse_cli
'Path to an NCBI Taxonomy dump directory to query instead of API calls',
'If the path is not passed, the dump is automatically downloaded'
) { |v| cli[:ncbi_taxonomy_dump] = v || true }
opt.on(
'--ignore-file', '::HIDE::' # Only for internal use
) { |v| cli[:ignore_file] = v }
end
end

Expand All @@ -100,17 +103,18 @@ def perform
private

def get_sub_cli
return [cli] if cli[:file].nil?
return [cli] if cli[:file].nil? || cli[:ignore_file]

glob = []
cli_default = cli.original_argv + ['--ignore-file']
File.open(cli[:file], 'r') do |fh|
h = nil
fh.each do |ln|
r = ln.chomp.split(/\t/)
if h.nil?
h = r
else
argv_i = [self.name]
argv_i = cli_default.dup
h.each_with_index do |field, k|
case field.downcase
when *%w[query ignore-dup get-metadata only-metadata]
Expand Down
4 changes: 2 additions & 2 deletions lib/miga/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ module MiGA
# - String indicating release status:
# - rc* release candidate, not released as gem
# - [0-9]+ stable release, released as gem
VERSION = [1.3, 13, 3].freeze
VERSION = [1.3, 13, 4].freeze

##
# Nickname for the current major.minor version.
VERSION_NAME = 'mezzotint'

##
# Date of the current gem relese.
VERSION_DATE = Date.new(2024, 3, 18)
VERSION_DATE = Date.new(2024, 3, 20)

##
# References of MiGA
Expand Down

0 comments on commit b43d9b1

Please sign in to comment.