Class: Publicity::Exec

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

Overview

Kicks off the parsing process by parsing command-line arguments and calling the method that parses each input file.

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Exec

Returns a new instance of Exec.

Parameters:

  • args (Array<String>)

    All command-line arguments



11
12
13
14
# File 'lib/publicity.rb', line 11

def initialize(args)
  @args = args
  @options = {}
end

Instance Method Details

#parseObject

Parses the command-line arguments and begins parsing the files.

See Also:



27
28
29
30
31
32
# File 'lib/publicity.rb', line 27

def parse
  @opts = OptionParser.new(&method(:set_opts))
  @opts.parse!(@args)

  process_result
end

#parse!Object

Parses the command-line arguments and begins parsing the files.

See Also:



19
20
21
22
# File 'lib/publicity.rb', line 19

def parse!
  parse
  exit 0
end

#process_resultObject

Kickstarts the script prompt



59
60
61
# File 'lib/publicity.rb', line 59

def process_result
  Publicity::Main.new
end

#set_opts(opts) ⇒ Object

Takes the command-line arguments and parses them for optparse.

Parameters:

  • opts (OptionParser)


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/publicity.rb', line 37

def set_opts(opts)
  opts.banner = <<EOS
publicity v#{Publicity::VERSION}

Description:

TODO

Usage (from within a .git repository):

  publicity [options]

Options:
EOS

  opts.on_tail( '-h', '--help', 'Display this screen' ) do
    puts opts
    exit
  end
end