Class: Shhh::App::Args

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

Constant Summary collapse

OPTIONS_REQUIRE_KEY =
%i(encrypt decrypt edit)
OPTIONS_KEY_CREATED =
%i(generate)
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

#generate_key?Boolean

Returns:

  • (Boolean)


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

def generate_key?
  do?(OPTIONS_KEY_CREATED)
end

#output_classObject



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

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

#require_key?Boolean

Returns:

  • (Boolean)


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

def require_key?
  do?(OPTIONS_REQUIRE_KEY)
end

#specify_key?Boolean

Returns:

  • (Boolean)


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

def specify_key?
  do?(OPTIONS_SPECIFY_KEY)
end