Class: TXPRails::Commands

Inherits:
Object
  • Object
show all
Defined in:
lib/txprails/commands.rb

Overview

This module handles miscelaneous command line utilities

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Commands

Returns a new instance of Commands.

Parameters:

  • args (Array<String>)

    The command-line arguments



8
9
10
11
12
13
# File 'lib/txprails/commands.rb', line 8

def initialize(args)
  @args = args
  @options = {}
  @options[:requires] = []    # ??
  @options[:load_paths] = []  # ??
end

Instance Method Details

#parse!Object

Parses the command-line arguments and runs the executable. Calls ‘Kernel#exit` at the end, so it never returns.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/txprails/commands.rb', line 17

def parse!
  begin
    @opts = OptionParser.new(&method(:set_opts))
    @opts.parse!(@args)
    @options
  rescue Exception => e
    raise e if e.is_a?(SystemExit)

    $stderr.puts e.message
    exit 1
  end
  exit 0
end

#to_sString

Returns A description of the executable.

Returns:

  • (String)

    A description of the executable



32
33
34
# File 'lib/txprails/commands.rb', line 32

def to_s
  @opts.to_s
end