Class: Ardb::CLI::InvalidCommand
- Inherits:
-
Object
- Object
- Ardb::CLI::InvalidCommand
- Defined in:
- lib/ardb/cli/commands.rb
Instance Attribute Summary collapse
-
#clirb ⇒ Object
readonly
Returns the value of attribute clirb.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #help ⇒ Object
-
#initialize(name) ⇒ InvalidCommand
constructor
A new instance of InvalidCommand.
- #new ⇒ Object
- #run(argv) ⇒ Object
Constructor Details
#initialize(name) ⇒ InvalidCommand
Returns a new instance of InvalidCommand.
15 16 17 18 |
# File 'lib/ardb/cli/commands.rb', line 15 def initialize(name) @name = name @clirb = CLIRB.new end |
Instance Attribute Details
#clirb ⇒ Object (readonly)
Returns the value of attribute clirb.
13 14 15 |
# File 'lib/ardb/cli/commands.rb', line 13 def clirb @clirb end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/ardb/cli/commands.rb', line 13 def name @name end |
Instance Method Details
#help ⇒ Object
28 29 30 31 32 33 |
# File 'lib/ardb/cli/commands.rb', line 28 def help "Usage: ardb [COMMAND] [options]\n\n" \ "Options: #{@clirb}\n" \ "Commands:\n" \ "#{COMMANDS.to_s.split("\n").map{ |l| " #{l}" }.join("\n")}\n" end |
#new ⇒ Object
20 |
# File 'lib/ardb/cli/commands.rb', line 20 def new; self; end |
#run(argv) ⇒ Object
22 23 24 25 26 |
# File 'lib/ardb/cli/commands.rb', line 22 def run(argv) @clirb.parse!([@name, argv].flatten.compact) raise CLIRB::HelpExit if @name.to_s.empty? raise InvalidCommandError, "'#{self.name}' is not a command." end |