Class: Lexdrill::CLI
- Inherits:
-
Object
- Object
- Lexdrill::CLI
- Defined in:
- lib/lexdrill/cli.rb
Constant Summary collapse
- COMMANDS =
{ print_version: %w[version --version -v], print_help: %w[help --help -h], run_next: %w[next], run_hook: %w[hook], run_start: %w[start], run_stop: %w[stop], run_inspect: %w[inspect] }.freeze
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #start ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
18 19 20 |
# File 'lib/lexdrill/cli.rb', line 18 def initialize(argv) @argv = argv end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
22 23 24 |
# File 'lib/lexdrill/cli.rb', line 22 def argv @argv end |
Class Method Details
.start(argv = ARGV) ⇒ Object
14 15 16 |
# File 'lib/lexdrill/cli.rb', line 14 def self.start(argv = ARGV) new(argv).start end |
Instance Method Details
#start ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/lexdrill/cli.rb', line 24 def start command = argv.first || "help" handler = COMMANDS.find { |_method, | .include?(command) }&.first return print_unknown_command(command) unless handler send(handler) end |