class CLI::Input

Slightly easifications for the setup of an OptionParser, used by subcommands

Attributes

app_name[R]

Application name (String)

command_name[R]

Command name (String)

Public Instance Methods

CLI::Input#add_help() → CLI::Input click to toggle source

Adding --help option is easy

# File lib/cli/input.rb, line 40
def add_help
  self.on('-h', '--help', 'Display this screen') do
    $stdout.puts self
    exit 0
  end
  return self
end
CLI::Input#from_command(Command command) → CLI::Input click to toggle source

Set app_name, command_name and program_name from Command command

# File lib/cli/input.rb, line 16
def from_command(command)
  @app_name     = command.app_name
  @command_name = command.command_name
  @program_name = '%s %s' % [@app_name, @command_name]
  return self
end
CLI::Input#make_banner() → CLI::Input click to toggle source
CLI::Input#make_banner(String add) → CLI::Input

Easify banner formatting, using correct app_name and command_name

# File lib/cli/input.rb, line 29
def make_banner(add=nil)
  self.banner = "Usage: %s %s %s" % [self.app_name,
                                     self.command_name,
                                     add ? add : '{OPTION}']
  return self
end