Module: Sevgi::Binaries::Sevgi

Extended by:
Sevgi
Included in:
Sevgi
Defined in:
lib/sevgi/binaries/sevgi.rb

Overview

Implements the sevgi executable.

Constant Summary collapse

PROGNAME =

Executable name used in help output.

"sevgi"
Error =

Error raised for invalid command-line usage.

Class.new(::Sevgi::Error)

Instance Method Summary collapse

Instance Method Details

#call(argv) ⇒ nil

Runs the sevgi command-line interface.

Parameters:

  • argv (Array<String>, String, nil)

    command-line arguments

Returns:

  • (nil)

Raises:

  • (LoadError)

    when a required Ruby library cannot be loaded

  • (Sevgi::Executor::Error)

    when --exception or SEVGI_VOMIT requests raw errors

  • (SystemExit)

    when command-line usage or script execution aborts



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/sevgi/binaries/sevgi.rb', line 62

def call(argv)
  return puts(help) if (options = Options.parse(argv = Array(argv))).help
  return puts(::Sevgi::VERSION) if options.version

  result = run(file = argv.shift, options)

  if result.error?
    raise result.error if options.vomit || ENV[ENVVOMIT]

    die(result.error, file)
  end

rescue Binaries::Sevgi::Error => e
  abort(e.message)
end