Class: Iev::Cli::Command

Inherits:
Thor
  • Object
show all
Includes:
CommandHelper
Defined in:
lib/iev/cli/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ui

debug, info, progress, set_ui_tag, warn

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/iev/cli/command.rb', line 43

def self.exit_on_failure?
  true
end

.shared_option(name, methods:, **kwargs) ⇒ Object

Options must be declared at the bottom because Thor must have commands defined in advance.



50
51
52
# File 'lib/iev/cli/command.rb', line 50

def self.shared_option(name, methods:, **kwargs)
  [*methods].each { |m| option name, for: m, **kwargs }
end

Instance Method Details

#db2yaml(dbfile) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/iev/cli/command.rb', line 34

def db2yaml(dbfile)
  handle_generic_options(options)
  db = Sequel.sqlite(dbfile)
  ds = filter_dataset(db, options)
  collection = build_collection_from_dataset(ds)
  save_collection_to_files(collection, options[:output])
  summary
end

#xlsx2db(file) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/iev/cli/command.rb', line 23

def xlsx2db(file)
  handle_generic_options(options)
  # Instantiating an in-memory db and dumping it later is faster than
  # just working on file db.
  db = Sequel.sqlite
  DbWriter.new(db).import_spreadsheet(file)
  save_db_to_file(db, options[:output])
  summary
end

#xlsx2yaml(file) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/iev/cli/command.rb', line 12

def xlsx2yaml(file)
  handle_generic_options(options)
  db = Sequel.sqlite
  DbWriter.new(db).import_spreadsheet(file)
  ds = filter_dataset(db, options)
  collection = build_collection_from_dataset(ds)
  save_collection_to_files(collection, options[:output])
  summary
end