Sha256: 24c1ba6bff3f4dab23973c72cb2f4f20872ef38ec481dd599f888750eb9c815c

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

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

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

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

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

9 entries across 9 versions & 1 rubygems

Version Path
flapjack-1.6.0 bin/flapjack
flapjack-1.6.0rc4 bin/flapjack
flapjack-1.6.0rc3 bin/flapjack
flapjack-1.6.0rc2 bin/flapjack
flapjack-1.6.0rc1 bin/flapjack
flapjack-1.5.0 bin/flapjack
flapjack-1.5.0rc1 bin/flapjack
flapjack-1.4.0 bin/flapjack
flapjack-1.4.0rc1 bin/flapjack