Class: Appsignal::CLI
- Inherits:
-
Object
- Object
- Appsignal::CLI
- Defined in:
- lib/appsignal/cli.rb
Constant Summary collapse
- AVAILABLE_COMMANDS =
%w(notify_of_deploy).freeze
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
-
.initial_config ⇒ Object
Returns the value of attribute initial_config.
-
.options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
- .command_option_parser ⇒ Object
- .global_option_parser ⇒ Object
- .logger ⇒ Object
- .notify_of_deploy ⇒ Object
- .run(argv = ARGV) ⇒ Object
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
11 12 13 |
# File 'lib/appsignal/cli.rb', line 11 def config @config end |
.initial_config ⇒ Object
Returns the value of attribute initial_config.
11 12 13 |
# File 'lib/appsignal/cli.rb', line 11 def initial_config @initial_config end |
.options ⇒ Object
Returns the value of attribute options.
11 12 13 |
# File 'lib/appsignal/cli.rb', line 11 def @options end |
Class Method Details
.command_option_parser ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/appsignal/cli.rb', line 71 def command_option_parser { 'notify_of_deploy' => OptionParser.new do |o| o. = 'Usage: appsignal notify_of_deploy [options]' o.on '--revision=<revision>', "The revision you're deploying" do |arg| [:revision] = arg end o.on '--user=<user>', "The name of the user that's deploying" do |arg| [:user] = arg end o.on '--environment=<rails_env>', "The environment you're deploying to" do |arg| [:environment] = arg end o.on '--name=<name>', "The name of the app (optional)" do |arg| initial_config[:name] = arg end end } end |
.global_option_parser ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/appsignal/cli.rb', line 52 def global_option_parser OptionParser.new do |o| o. = '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 |
.logger ⇒ Object
39 40 41 |
# File 'lib/appsignal/cli.rb', line 39 def logger Logger.new($stdout) end |
.notify_of_deploy ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/appsignal/cli.rb', line 95 def notify_of_deploy validate_active_config ([:revision, :user, :environment]) Appsignal::Marker.new( { :revision => [:revision], :user => [:user] }, config, logger ).transmit end |
.run(argv = ARGV) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/appsignal/cli.rb', line 13 def run(argv=ARGV) @options = {} @initial_config = {} 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 :notify_of_deploy notify_of_deploy end else puts "Command '#{command}' does not exist, run appsignal -h to "\ "see the help" exit(1) end else # Print help puts global exit(0) end end |