Sha256: d22a4636dde06b138bf5d94bd176e44b4c5c6e12de0f6468c70dacfd0bfc88aa

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

#!/usr/bin/env ruby

require 'gli'
require 'flapjack/version'

$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'
flag [:c,:config],
  :arg_name => '/path/to/flapjack.toml',
  :default_value => '/etc/flapjack/flapjack_config.toml'

desc 'Force UTF-8 encoding'
switch [:'force-utf8'],
  :negatable => true,
  :default_value => true

accept Array do |value|
  value.split(/,/).map(&:strip)
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

3 entries across 3 versions & 1 rubygems

Version Path
flapjack-2.0.0 bin/flapjack
flapjack-2.0.0rc1 bin/flapjack
flapjack-2.0.0b1 bin/flapjack