Class: Morpheus::Cli::ColoringCommand
- Inherits:
-
Object
- Object
- Morpheus::Cli::ColoringCommand
- Includes:
- CliCommand
- Defined in:
- lib/morpheus/cli/coloring_command.rb
Overview
This is for use in dotfile scripts It allows you to turn colors on or off globally
Instance Attribute Summary
Attributes included from CliCommand
Instance Method Summary collapse
Methods included from CliCommand
#build_common_options, #build_option_type_options, #command_name, #default_subcommand, #establish_remote_appliance_connection, #handle_subcommand, included, #interactive?, #noninteractive, #print_usage, #subcommand_aliases, #subcommand_usage, #subcommands, #usage, #verify_access_token!
Instance Method Details
#handle(args) ⇒ Object
12 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/morpheus/cli/coloring_command.rb', line 12 def handle(args) append_newline = true = {} optparse = Morpheus::Cli::OptionParser.new do|opts| opts. = "Usage: morpheus #{command_name} [on|off]" #build_common_options(opts, options, []) opts.on('-h', '--help', "Prints this help" ) do puts opts exit end opts. = "Enable [on] or Disable [off] ANSI Colors for all output." end optparse.parse!(args) if args.count != 1 puts optparse exit 1 end is_on = ["on","true", "1"].include?(args[0].to_s.strip.downcase) is_off = ["off","false", "0"].include?(args[0].to_s.strip.downcase) if !is_on && !is_off puts optparse exit 1 end Term::ANSIColor::coloring = is_on return true end |