Module: CommandKit::Main

Extended by:
ModuleMethods
Included in:
Arguments, Command, Options::Parser
Defined in:
lib/command_kit/main.rb

Overview

Defines a main method.

Examples

include CommandKit::Main

def main(argv=[])
  # ...
  return 0
end

Defined Under Namespace

Modules: ClassMethods, ModuleMethods

Instance Method Summary collapse

Methods included from ModuleMethods

included

Instance Method Details

#main(argv = []) ⇒ Integer

Note:

argv is splatted into #run.

Place-holder main method, which parses options, before calling #run.

Parameters:

  • argv (Array<String>) (defaults to: [])

    The Array of command-line arguments.

Returns:

  • (Integer)

    The exit status code.



96
97
98
99
100
101
# File 'lib/command_kit/main.rb', line 96

def main(argv=[])
  run(*argv)
  return 0
rescue SystemExit => system_exit
  return system_exit.status
end

#run(*args) ⇒ Object

This method is abstract.

Place-holder method for command business logic.

Parameters:

  • args (Array<Object>)

    Additional arguments for the command.



113
114
# File 'lib/command_kit/main.rb', line 113

def run(*args)
end