Class: Lapine::CLI
- Inherits:
-
Object
- Object
- Lapine::CLI
- Defined in:
- lib/lapine/cli.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Instance Method Summary collapse
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
- #usage ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
5 6 7 8 |
# File 'lib/lapine/cli.rb', line 5 def initialize(argv) @argv = argv @command = argv.shift end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
3 4 5 |
# File 'lib/lapine/cli.rb', line 3 def argv @argv end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
3 4 5 |
# File 'lib/lapine/cli.rb', line 3 def command @command end |
Instance Method Details
#run ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/lapine/cli.rb', line 10 def run case command when 'consume' require 'lapine/consumer' ::Lapine::Consumer::Runner.new(argv).run else usage end end |
#usage ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/lapine/cli.rb', line 20 def usage puts <<-EOF.gsub(/^ {8}/, '') Usage: lapine [command] [options] commands: consume EOF exit 1 end |