Module: Scripting::AppDefaults

Defined in:
lib/scripting/app_defaults.rb

Class Method Summary collapse

Class Method Details

.instance_init(instance, *args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/scripting/app_defaults.rb', line 4

def self.instance_init(instance, *args)
  instance.instance_eval do
    options do
      verbose false
      debug false
    end

    switches do
      on_tail('-v', '--verbose', 'Enable verbose output') do
        options.verbose = true
      end

      on_tail('-D', '--debug', 'Enable debug output') do
        options.debug = true
      end

      on_tail('-h', '--help', "Help text") do
        context.clear_work!
        context.help!
        terminate
      end
    end
  end
end