module Mixlib::CLI::ClassMethods

def banner(bstring = nil)

@banner:: The current banner
=== Returns

bstring:: The string to set the banner to
=== Parameters

Usage: #{0} (options)
Change the banner. Defaults to:
def banner(bstring = nil)
  if bstring
    @banner = bstring
  else
    @banner ||= "Usage: #{$0} (options)"
    @banner
  end
end

def deprecated_option(name,

:: The config hash for the created option.
=== Returns

to non-deprecated keys in your code.
if no replacement is provided. You can use this to enforce the transition
only the value in `replacement` will be set. Results undefined
populated when the deprecated flag is used. If set to false,
keep :: Defaults to true, this ensures that `options[:deprecated_flag]` is
assigned directly to the converted option.
If not provided, the value provided to the deprecated option will be
and converts it to a value suitable for the new option.
value_mapper :: a block that accepts the original value from the deprecated option,
boolean :: true if this is a boolean flag, eg "--[no-]option".
short :: The original short-form flag name, eg "-u USER"
long :: The original long flag name, or flag name with argument, eg "--user USER"
replacement :: The name of the option that replaces this option.
name :: The name of the deprecated option

Add a deprecated command line option.

Declare a deprecated option
def deprecated_option(name,
  replacement: nil,
  long: nil,
  short: nil,
  boolean: false,
  value_mapper: nil,
  keep: true)
  description = if replacement
                  replacement_cfg = options[replacement]
                  display_name = CLI::Formatter.combined_option_display_name(replacement_cfg[:short], replacement_cfg[:long])
                  "This flag is deprecated. Use #{display_name} instead."
                else
                  "This flag is deprecated and will be removed in a future release."
                end
  value_mapper ||= Proc.new { |v| v }
  option(name,
    long: long,
    short: short,
    boolean: boolean,
    description: description,
    on: :tail,
    deprecated: true,
    keep: keep,
    replacement: replacement,
    value_mapper: value_mapper)
end

def option(name, args)

Returns:
  • (Hash) - :: the config hash for the created option
def option(name, args)
  @options ||= {}
  raise(ArgumentError, "Option name must be a symbol") unless name.is_a?(Symbol)
  @options[name.to_sym] = args
end

def options

@options:: The current options hash.
=== Returns

Get the hash of current options.
def options
  @options ||= {}
  @options
end

def options=(val)

@options:: The current options hash.
=== Returns

val:: The hash to set the options to
=== Parameters

Set the current options hash
def options=(val)
  raise(ArgumentError, "Options must receive a hash") unless val.is_a?(Hash)
  @options = val
end

def use_separate_default_options(true_or_false)

mixlib-cli DSL will be stored in a separate Hash
When this setting is set to +true+, default values supplied to the
def use_separate_default_options(true_or_false)
  @separate_default_options = true_or_false
end

def use_separate_defaults?

def use_separate_defaults?
  @separate_default_options ||= false
end