Method: Processing::Runner#parse_options

Defined in:
lib/picrate/runner.rb

#parse_options(args) ⇒ Object

Parse the command-line options. Keep it simple.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/picrate/runner.rb', line 31

def parse_options(args)
  opt_parser = OptionParser.new do |opts|
    # Set a banner, displayed at the top
    # of the help screen.
    opts.banner = 'Usage: picrate [options] [<name>]'

    # Define the options, and what they do
    options[:version] = false
    opts.on('-v', '--version', 'PiCrate Version') do
      options[:version] = true
    end

    options[:install] = false
    message = '<Samples><Video> Install samples or library'
    opts.on('-i', '--install', message) do
      options[:install] = true
    end

    options[:create] = false
    opts.on('-c', '--create', 'Create new sketch outline') do
      options[:create] = true
    end

    # This displays the help screen, all programs are
    # assumed to have this option.
    opts.on_tail('-h', '--help', 'Display this screen') do
      puts opts
      puts ''
      puts 'Run a sketch: jruby [--dev] [<sketch.rb>]'
      exit
    end
  end
  @argc = opt_parser.parse(args)
  @filename = argc.shift
end