Module: GemFast::Command
- Extended by:
- UI
- Defined in:
- lib/gem-fast/command.rb
Defined Under Namespace
Classes: Base, CommandFailed, InvalidCommand
Class Method Summary
collapse
Class Method Details
.parse(command) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/gem-fast/command.rb', line 48
def parse(command)
parts = command.split(':')
case parts.size
when 1
begin
return eval("GemFast::Command::#{command.capitalize}"), :index
end
when 2
begin
return GemFast::Command.const_get(parts[0].capitalize), parts[1]
rescue NameError
raise InvalidCommand
end
else
raise InvalidCommand
end
end
|
.run(command, args, retries = 0) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/gem-fast/command.rb', line 29
def run(command, args, retries=0)
begin
run_internal(command, args.dup)
rescue InvalidCommand
error "Unknown command. Run 'autoweb help' for usage information."
rescue CommandFailed => e
error e.message
rescue Interrupt => e
error "\n[canceled]"
end
end
|
.run_internal(command, args) ⇒ Object
41
42
43
44
45
46
|
# File 'lib/gem-fast/command.rb', line 41
def run_internal(command, args)
klass, method = parse(command)
runner = klass.new(args)
raise InvalidCommand unless runner.respond_to?(method)
runner.send(method)
end
|