Class: WIP::Runner::CLI
- Inherits:
-
Object
show all
- Defined in:
- lib/wip/runner/cli.rb
Defined Under Namespace
Classes: Help, Parser, Version
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(ui = UI.new) ⇒ CLI
Returns a new instance of CLI.
41
42
43
44
45
46
|
# File 'lib/wip/runner/cli.rb', line 41
def initialize(ui = UI.new)
@ui = ui
@parser = Parser.new(ui)
trap('INT') { quit }
trap('TERM') { quit }
end
|
Class Method Details
.allow(path, search) ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/wip/runner/cli.rb', line 5
def allow(path, search)
search.each do |dir|
extension = File.join(dir, path)
if File.exist?("#{extension}.rb")
$:.push(File.join(extension, 'lib'))
require extension
assets(File.join(extension, 'assets'))
end
end
end
|
.assets(*paths) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/wip/runner/cli.rb', line 32
def assets(*paths)
@assets ||= []
unless paths.empty?
@assets = (@assets + paths.flatten).uniq
end
@assets
end
|
.namespace ⇒ Object
28
29
30
|
# File 'lib/wip/runner/cli.rb', line 28
def namespace
@namespace || WIP::Runner
end
|
.namespace=(value) ⇒ Object
24
25
26
|
# File 'lib/wip/runner/cli.rb', line 24
def namespace=(value)
@namespace = value
end
|
.signature ⇒ Object
20
21
22
|
# File 'lib/wip/runner/cli.rb', line 20
def signature
@signature || 'wip-runner'
end
|
.signature=(value) ⇒ Object
16
17
18
|
# File 'lib/wip/runner/cli.rb', line 16
def signature=(value)
@signature = value
end
|
Instance Method Details
#quit ⇒ Object
48
49
50
|
# File 'lib/wip/runner/cli.rb', line 48
def quit
exit
end
|
#run(argv = []) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/wip/runner/cli.rb', line 52
def run(argv = [])
args = argv.dup
recipient = (command(args) || @parser)
recipient.run(args)
rescue InvalidCommand => e
@ui.err {
@ui.say(e.message)
@ui.newline
}
@parser.help
end
|