Class: Appsignal::CLI
- Inherits:
-
Object
show all
- Defined in:
- lib/appsignal/cli.rb,
lib/appsignal/cli/demo.rb,
lib/appsignal/cli/install.rb,
lib/appsignal/cli/diagnose.rb,
lib/appsignal/cli/notify_of_deploy.rb
Defined Under Namespace
Classes: Demo, Diagnose, Install, NotifyOfDeploy
Constant Summary
collapse
- AVAILABLE_COMMANDS =
%w(demo diagnose install notify_of_deploy).freeze
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
Returns the value of attribute options.
15
16
17
|
# File 'lib/appsignal/cli.rb', line 15
def options
@options
end
|
Class Method Details
.command_option_parser ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/appsignal/cli.rb', line 76
def command_option_parser
{
'demo' => OptionParser.new do |o|
o.banner = 'Usage: appsignal demo [options]'
o.on '--environment=<rails_env>', "The environment to demo" do |arg|
options[:environment] = arg
end
end,
'diagnose' => OptionParser.new,
'install' => OptionParser.new,
'notify_of_deploy' => OptionParser.new do |o|
o.banner = 'Usage: appsignal notify_of_deploy [options]'
o.on '--revision=<revision>', "The revision you're deploying" do |arg|
options[:revision] = arg
end
o.on '--user=<user>', "The name of the user that's deploying" do |arg|
options[:user] = arg
end
o.on '--environment=<rails_env>', "The environment you're deploying to" do |arg|
options[:environment] = arg
end
o.on '--name=<name>', "The name of the app (optional)" do |arg|
options[:name] = arg
end
end
}
end
|
48
49
50
51
52
53
54
55
|
# File 'lib/appsignal/cli.rb', line 48
def config
Appsignal::Config.new(
Dir.pwd,
options[:environment],
{},
Logger.new(StringIO.new)
)
end
|
.global_option_parser ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/appsignal/cli.rb', line 57
def global_option_parser
OptionParser.new do |o|
o.banner = 'Usage: appsignal <command> [options]'
o.on '-v', '--version', "Print version and exit" do |arg|
puts "AppSignal #{Appsignal::VERSION}"
exit(0)
end
o.on '-h', '--help', "Show help and exit" do
puts o
exit(0)
end
o.separator ''
o.separator "Available commands: #{AVAILABLE_COMMANDS.join(', ')}"
end
end
|
.run(argv = ARGV) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/appsignal/cli.rb', line 17
def run(argv=ARGV)
@options = {}
global = global_option_parser
commands = command_option_parser
global.order!(argv)
command = argv.shift
if command
if AVAILABLE_COMMANDS.include?(command)
commands[command].parse!(argv)
case command.to_sym
when :demo
Appsignal::CLI::Demo.run(options)
when :diagnose
Appsignal::CLI::Diagnose.run
when :install
Appsignal::CLI::Install.run(argv.shift, config)
when :notify_of_deploy
Appsignal::CLI::NotifyOfDeploy.run(options)
end
else
puts "Command '#{command}' does not exist, run appsignal -h to "\
"see the help"
exit(1)
end
else
puts global
exit(0)
end
end
|