Class: SecretKeys::CLI::Base
- Inherits:
-
Object
- Object
- SecretKeys::CLI::Base
- Defined in:
- lib/secret_keys/cli.rb
Constant Summary collapse
- MAX_SUMMARY_LENGTH =
80
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#secret_key ⇒ Object
readonly
Returns the value of attribute secret_key.
Instance Method Summary collapse
-
#action_name ⇒ Object
Subclasses should return the action name for the help banner.
-
#format ⇒ Object
Return the output format.
-
#initialize(argv) ⇒ Base
constructor
A new instance of Base.
-
#parse_additional_options(opts) ⇒ Object
Subclasses can override this method to parse additional options beyond the standard set.
-
#run! ⇒ Object
Subclasses must implement this method to execute the logic.
-
#secrets ⇒ SecretKeys
The secrets.
Constructor Details
#initialize(argv) ⇒ Base
Returns a new instance of Base.
14 15 16 17 18 19 |
# File 'lib/secret_keys/cli.rb', line 14 def initialize(argv) # make sure we can only use stdin once @stdin_used = false @secrets = nil (argv) end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
10 11 12 |
# File 'lib/secret_keys/cli.rb', line 10 def input @input end |
#secret_key ⇒ Object (readonly)
Returns the value of attribute secret_key.
10 11 12 |
# File 'lib/secret_keys/cli.rb', line 10 def secret_key @secret_key end |
Instance Method Details
#action_name ⇒ Object
Subclasses should return the action name for the help banner
31 32 33 |
# File 'lib/secret_keys/cli.rb', line 31 def action_name "<encrypt|decrypt|read|edit>" end |
#format ⇒ Object
Return the output format.
41 42 43 44 |
# File 'lib/secret_keys/cli.rb', line 41 def format return @format if [:json, :yaml].include?(@format) secrets.input_format end |
#parse_additional_options(opts) ⇒ Object
Subclasses can override this method to parse additional options beyond the standard set.
22 23 |
# File 'lib/secret_keys/cli.rb', line 22 def (opts) end |
#run! ⇒ Object
Subclasses must implement this method to execute the logic.
36 37 38 |
# File 'lib/secret_keys/cli.rb', line 36 def run! raise NotImplementedError end |
#secrets ⇒ SecretKeys
Returns the secrets.
26 27 28 |
# File 'lib/secret_keys/cli.rb', line 26 def secrets @secrets ||= SecretKeys.new(@input, @secret_key) end |