Class: GGem::CLI::InvalidCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/ggem/cli/commands.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ InvalidCommand

Returns a new instance of InvalidCommand.



15
16
17
18
# File 'lib/ggem/cli/commands.rb', line 15

def initialize(name)
  @name  = name
  @clirb = CLIRB.new
end

Instance Attribute Details

#clirbObject (readonly)

Returns the value of attribute clirb.



13
14
15
# File 'lib/ggem/cli/commands.rb', line 13

def clirb
  @clirb
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/ggem/cli/commands.rb', line 13

def name
  @name
end

Instance Method Details

#helpObject



30
31
32
33
34
35
# File 'lib/ggem/cli/commands.rb', line 30

def help
  "Usage: ggem [COMMAND] [options]\n\n" \
  "Options: #{@clirb}\n" \
  "Commands:\n" \
  "#{COMMANDS.to_s.split("\n").map{ |l| "  #{l}" }.join("\n")}\n"
end

#newObject



20
21
22
# File 'lib/ggem/cli/commands.rb', line 20

def new
  self
end

#run(argv) ⇒ Object

Raises:



24
25
26
27
28
# File 'lib/ggem/cli/commands.rb', line 24

def run(argv)
  @clirb.parse!([@name, argv].flatten.compact)
  raise CLIRB::HelpExit if @name.to_s.empty?
  raise InvalidCommandError, "`#{name}` is not a command."
end