module Mixlib::CLI::ClassMethods

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 ensure sthat `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