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], run_beat: %w[beat], run_beat_alias: %w[polka waltz rock jazz jiga balkan samba], run_color: %w[color], run_add: %w[add], run_list: %w[list], run_edit: %w[edit], run_stats: %w[stats], run_rand: %w[rand], run_go: %w[go], run_remote: %w[remote], run_oauth: %w[oauth], run_wb: %w[wb], run_sh: %w[sh], run_open: %w[open], run_push: %w[push], run_pull: %w[pull] }.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.
34 35 36 |
# File 'lib/lexdrill/cli.rb', line 34 def initialize(argv) @argv = argv end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
38 39 40 |
# File 'lib/lexdrill/cli.rb', line 38 def argv @argv end |
Class Method Details
.start(argv = ARGV) ⇒ Object
30 31 32 |
# File 'lib/lexdrill/cli.rb', line 30 def self.start(argv = ARGV) new(argv).start end |
Instance Method Details
#start ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/lexdrill/cli.rb', line 40 def start command = argv.first || "help" handler = COMMANDS.find { |_method, | .include?(command) }&.first return print_unknown_command(command) unless handler send(handler) end |