Class: Ardb::CLI::InvalidCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/ardb/cli.rb,
lib/ardb/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ InvalidCommand

Returns a new instance of InvalidCommand.



75
76
77
78
79
# File 'lib/ardb/cli.rb', line 75

def initialize(name)
  @name  = name
  @argv  = []
  @clirb = Ardb::CLIRB.new
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



73
74
75
# File 'lib/ardb/cli.rb', line 73

def argv
  @argv
end

#clirbObject (readonly)

Returns the value of attribute clirb.



73
74
75
# File 'lib/ardb/cli.rb', line 73

def clirb
  @clirb
end

#nameObject (readonly)

Returns the value of attribute name.



73
74
75
# File 'lib/ardb/cli.rb', line 73

def name
  @name
end

Instance Method Details

#helpObject



92
93
94
95
96
# File 'lib/ardb/cli.rb', line 92

def help
  "Usage: ardb [COMMAND] [options]\n\n" \
  "Commands: #{COMMANDS.keys.sort.join(', ')}\n" \
  "Options: #{@clirb}"
end

#new(args) ⇒ Object



81
82
83
84
# File 'lib/ardb/cli.rb', line 81

def new(args)
  @argv = [@name, args].flatten.compact
  self
end

#runObject

Raises:



86
87
88
89
90
# File 'lib/ardb/cli.rb', line 86

def run
  @clirb.parse!(@argv)
  raise CLIRB::HelpExit if @clirb.args.empty? || @name.to_s.empty?
  raise InvalidCommandError, "'#{self.name}' is not a command."
end