Module: CommandKit::Main::ClassMethods

Defined in:
lib/command_kit/main.rb

Overview

Class-level methods.

Instance Method Summary collapse

Instance Method Details

#main(argv = [], **kwargs) ⇒ Integer

Initializes the command class with the given keyword arguments, then calls main with the given argv.

Parameters:

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

    The Array of command-line arguments.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments to initialize the command class with.

Returns:

  • (Integer)

    The exit status of the command.



78
79
80
# File 'lib/command_kit/main.rb', line 78

def main(argv=[], **kwargs)
  new(**kwargs).main(argv)
end

#start(argv = ARGV, **kwargs) ⇒ Object

Starts the command and then exits.

Parameters:

  • argv (Array<String>) (defaults to: ARGV)

    The Array of command-line arguments.



53
54
55
56
57
58
59
60
61
# File 'lib/command_kit/main.rb', line 53

def start(argv=ARGV, **kwargs)
  exit main(argv, **kwargs)
rescue Interrupt
  # https://tldp.org/LDP/abs/html/exitcodes.html
  exit 130
rescue Errno::EPIPE
  # STDOUT pipe broken
  exit 0
end