Class: Shhh::App::Args

Inherits:
Object
  • Object
show all
Defined in:
lib/shhh/app/args.rb

Constant Summary collapse

OPTIONS_MODE_SELECTED =
%i(encrypt decrypt generate edit keychain)
OPTIONS_REQUIRE_KEY =
%i(encrypt decrypt edit)
OPTIONS_SPECIFY_KEY =
%i(private_key interactive keyfile keychain)
OPTIONS_SPECIFY_OUTPUT =
%i(output quiet)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Args

Returns a new instance of Args.



13
14
15
16
# File 'lib/shhh/app/args.rb', line 13

def initialize(opts)
  self.opts             = opts
  self.selected_options = opts.keys.reject { |k| !opts[k] }
end

Instance Attribute Details

#optsObject

Returns the value of attribute opts.



11
12
13
# File 'lib/shhh/app/args.rb', line 11

def opts
  @opts
end

#selected_optionsObject

Returns the value of attribute selected_options.



11
12
13
# File 'lib/shhh/app/args.rb', line 11

def selected_options
  @selected_options
end

Instance Method Details

#do_options_require_key?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/shhh/app/args.rb', line 27

def do_options_require_key?
  do?(OPTIONS_REQUIRE_KEY)
end

#do_options_specify_key?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/shhh/app/args.rb', line 23

def do_options_specify_key?
  do?(OPTIONS_SPECIFY_KEY)
end

#do_options_specify_mode?Boolean

TODO: generate these methods dynamically

Returns:

  • (Boolean)


19
20
21
# File 'lib/shhh/app/args.rb', line 19

def do_options_specify_mode?
  do?(OPTIONS_MODE_SELECTED)
end

#output_classObject



31
32
33
34
# File 'lib/shhh/app/args.rb', line 31

def output_class
  output_type = OPTIONS_SPECIFY_OUTPUT.find { |o| opts[o] } # includes nil
  Shhh::App::Output.outputs[output_type]
end