Skip to content

Adding Commonly Used Options

mosop edited this page Dec 11, 2016 · 4 revisions

Help

The Options.help method adds the -h and --help options to your command. These options can be used to print a help message.

class Command < Cli::Command
  class Options
    help # equivalent to on(%w(-h --help)) { command.help! }
  end
end

You can change the option's name:

class Command < Cli::Command
  class Options
    help "--show-help"
  end
end

Version

The Options.version method adds the -v and --version options to your command. These options can be used to print a version string.

class Command < Cli::Command
  class Options
    version # equivalent to on(%w(-v --version)) { command.version! }
  end
end

You can change the option's name:

class Command < Cli::Command
  class Options
    version "--show-version"
  end
end

Clone this wiki locally