Class: Sputnik::CLI
- Inherits:
-
Object
show all
- Defined in:
- lib/sputnik/cli.rb,
lib/sputnik/cli/setup.rb,
lib/sputnik/cli/console.rb,
lib/sputnik/cli/namespace_command_loader.rb
Defined Under Namespace
Classes: Console, NamespaceCommandLoader, Setup
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(loader = NamespaceCommandLoader.new, console = Console.new, setup = Setup.new) ⇒ CLI
8
9
10
11
12
|
# File 'lib/sputnik/cli.rb', line 8
def initialize(loader = NamespaceCommandLoader.new, console = Console.new, setup = Setup.new)
@loader = loader
@console = console
@setup = setup
end
|
Class Method Details
.start(*args) ⇒ Object
27
28
29
|
# File 'lib/sputnik/cli.rb', line 27
def start(*args)
new.start *args
end
|
Instance Method Details
#start(*args) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/sputnik/cli.rb', line 14
def start(*args)
@setup.call *args
if cmd = @loader[args.first]
cmd.call *args.slice(1..-1)
return 0
end
fail UnknownCommandError, args.first
rescue Exception => e
@console.error(e)
e.respond_to?(:to_exit_status) ? e.to_exit_status : 1
end
|