Class: PWN::Driver::Parser
- Inherits:
-
OptionParser
- Object
- OptionParser
- PWN::Driver::Parser
- Defined in:
- lib/pwn/driver.rb
Overview
Add OptionParser options to PWN::Env
Instance Attribute Summary collapse
-
#auto_opts_help ⇒ Object
Returns the value of attribute auto_opts_help.
-
#opts ⇒ Object
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #parse! ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pwn/driver.rb', line 13 def initialize super @opts = PWN::Env[:driver_opts] @auto_opts_help = true = "USAGE: #{File.basename($PROGRAM_NAME)} [opts]\n" on( '-YPATH', '--pwn_env=PATH', '<Optional - PWN::Env YAML file path (Default: ~/.pwn/pwn.yaml)>' ) do |o| @opts[:pwn_env_path] = o end on( '-ZPATH', '--pwn_dec=PATH', '<Optional - Out-of-Band YAML file path (Default: ~/.pwn/pwn.decryptor.yaml)>' ) do |o| @opts[:pwn_dec_path] = o end on_tail( '-v', '--version', 'Print PWN version and exit' ) do puts PWN::VERSION exit 0 end end |
Instance Attribute Details
#auto_opts_help ⇒ Object
Returns the value of attribute auto_opts_help.
10 11 12 |
# File 'lib/pwn/driver.rb', line 10 def auto_opts_help @auto_opts_help end |
#opts ⇒ Object
Returns the value of attribute opts.
10 11 12 |
# File 'lib/pwn/driver.rb', line 10 def opts @opts end |
Instance Method Details
#parse! ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/pwn/driver.rb', line 44 def parse! super(ARGV, into: @opts) # puts @opts PWN::Config.refresh_env( pwn_env_path: @opts[:pwn_env_path], pwn_dec_path: @opts[:pwn_dec_path] ) if @auto_opts_help && @opts.keys.join(' ') == 'pwn_env_path pwn_dec_path' puts `#{File.basename($PROGRAM_NAME)} --help` exit 1 end end |