Sha256: 8aa711a357b94c47af7d6c0d02ddbcda26873281c9c72d2a356e1f6e12a3fcb1

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 KB

Contents

#!/usr/bin/env ruby

require 'gli'

$stdout.sync = true

include GLI::App
subcommand_option_handling :normal
sort_help :manually
commands_from 'flapjack/cli'

program_desc 'Flexible monitoring notification routing system'

version Flapjack::VERSION

desc 'Configuration file to use'
default_value '/etc/flapjack/flapjack_config.yaml'
arg_name '/path/to/flapjack.yaml'
flag [:c,:config]

desc 'Environment to boot'
default_value 'production'
arg_name '<environment>'
flag [:n, :env, :environment]

accept Array do |value|
  value.split(/,/).map(&:strip)
end

pre do |global,command,options,args|
  FLAPJACK_ENV = ENV["FLAPJACK_ENV"] || global[:environment]
  true
end

post do |global,command,options,args|
end

on_error do |exception|
  # We've changed the commands to control the flapjack server.  If we detect
  # the user has tried one of the old commands, show them what they should
  # have used instead.
  SERVER_COMMANDS = %w(start stop restart reload status)
  message = exception.message
  input = message.split("'").last.downcase
  old_command = message.start_with?('Unknown command') && SERVER_COMMANDS.include?(input)
  if old_command
    puts exception.message
    puts "\nDid you mean: #{$PROGRAM_NAME} server #{input}?"
    puts "\nTry #{$PROGRAM_NAME} help"
  end
  # If this wasn't an old server command, return true to show the standard error dialog
  !old_command
end

exit run(ARGV)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flapjack-1.3.0 bin/flapjack
flapjack-1.3.0rc3 bin/flapjack
flapjack-1.3.0rc2 bin/flapjack
flapjack-1.3.0rc1 bin/flapjack
flapjack-1.2.2 bin/flapjack