Class: MiGA::Cli::Action
Overview
An action to be performed by the CLI. This is a generic class to be extended by MiGA::Cli::Action::* classes. Do not attempt creating directly with new
, use instead the MiGA::Cli::Action.load interface.
Direct Known Subclasses
About, Add, AddResult, Archive, Browse, ClassifyWf, Console, Daemon, Date, DerepWf, Doctor, Edit, Env, Files, Find, Generic, Get, GetDb, GtdbGet, IndexWf, Init, Lair, Ln, Ls, NcbiGet, New, NextStep, Option, PreprocWf, QualityWf, Rm, Run, Stats, Summary, TaxDist, TaxIndex, TaxSet, TaxTest, Touch
Defined Under Namespace
Modules: Download, Wf Classes: About, Add, AddResult, Archive, Browse, ClassifyWf, Console, Daemon, Date, DerepWf, Doctor, Edit, Env, Files, Find, Generic, Get, GetDb, GtdbGet, IndexWf, Init, Lair, Ln, Ls, NcbiGet, New, NextStep, Option, PreprocWf, QualityWf, Rm, Run, Stats, Summary, TaxDist, TaxIndex, TaxSet, TaxTest, Touch
Constant Summary
Constants included from MiGA
MiGA::CITATION, VERSION, VERSION_DATE, VERSION_NAME
Instance Attribute Summary collapse
-
#cli ⇒ Object
Returns the value of attribute cli.
Class Method Summary collapse
Instance Method Summary collapse
-
#complete ⇒ Object
Complete the action.
-
#empty_action ⇒ Object
What to do when cli.argv is empty.
-
#initialize(cli) ⇒ Action
constructor
A new instance of Action.
-
#launch ⇒ Object
Launch the sequence.
-
#name ⇒ Object
Name of the action, as referred to by the CLI.
-
#parse_cli ⇒ Object
Parse the CLI object.
-
#perform ⇒ Object
Perform the action.
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
#initialize(cli) ⇒ Action
Returns a new instance of Action.
22 23 24 |
# File 'lib/miga/cli/action.rb', line 22 def initialize(cli) @cli = cli end |
Instance Attribute Details
#cli ⇒ Object
Returns the value of attribute cli.
20 21 22 |
# File 'lib/miga/cli/action.rb', line 20 def cli @cli end |
Class Method Details
.load(task, cli) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/miga/cli/action.rb', line 12 def load(task, cli) require "miga/cli/action/#{task}" camel = task.to_s.gsub(/(?:_|^)(\S)/, &:upcase).delete('_') klass = Object.const_get("MiGA::Cli::Action::#{camel}") klass.new(cli) end |
Instance Method Details
#complete ⇒ Object
Complete the action
50 51 52 |
# File 'lib/miga/cli/action.rb', line 50 def complete cli.say 'Done' end |
#empty_action ⇒ Object
What to do when cli.argv is empty
63 64 65 |
# File 'lib/miga/cli/action.rb', line 63 def empty_action cli.argv << '-h' end |
#launch ⇒ Object
Launch the sequence
28 29 30 31 32 33 34 |
# File 'lib/miga/cli/action.rb', line 28 def launch MiGA.DEBUG 'Cli::Action.launch' empty_action if cli.argv.empty? parse_cli perform complete end |
#name ⇒ Object
Name of the action, as referred to by the CLI
56 57 58 59 |
# File 'lib/miga/cli/action.rb', line 56 def name camel = self.class.to_s.gsub(/.*::/, '') camel.gsub(/(\S)([A-Z])/, '\1_\2').downcase end |
#parse_cli ⇒ Object
Parse the CLI object
38 39 40 |
# File 'lib/miga/cli/action.rb', line 38 def parse_cli raise "Undefined interface for the command line of #{cli.task}" end |
#perform ⇒ Object
Perform the action
44 45 46 |
# File 'lib/miga/cli/action.rb', line 44 def perform raise "Undefined action for the command line of #{cli.task}" end |