Class: Sym::App::Commands::BaseCommand
- Inherits:
-
Object
- Object
- Sym::App::Commands::BaseCommand
show all
- Extended by:
- Forwardable
- Includes:
- Sym
- Defined in:
- lib/sym/app/commands/base_command.rb
Direct Known Subclasses
BashCompletion, Decrypt, Encrypt, GenerateKey, KeychainAddKey, OpenEditor, PasswordProtectKey, PrintKey, ShowExamples, ShowHelp, ShowVersion
Constant Summary
Constants included
from Sym
DESCRIPTION, VERSION
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Sym
config, default_key, default_key?, default_key_file
Constructor Details
#initialize(application) ⇒ BaseCommand
Returns a new instance of BaseCommand.
56
57
58
|
# File 'lib/sym/app/commands/base_command.rb', line 56
def initialize(application)
self.application = application
end
|
Instance Attribute Details
#application ⇒ Object
Returns the value of attribute application.
52
53
54
|
# File 'lib/sym/app/commands/base_command.rb', line 52
def application
@application
end
|
Instance Method Details
#add_password_to_the_cache(encrypted_key, password) ⇒ Object
90
91
92
|
# File 'lib/sym/app/commands/base_command.rb', line 90
def add_password_to_the_cache(encrypted_key, password)
self.application.password_cache[encrypted_key] = password
end
|
#add_to_keychain_if_needed(key) ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/sym/app/commands/base_command.rb', line 76
def add_to_keychain_if_needed(key)
if opts[:keychain] && Sym::App.osx?
Sym::App::KeyChain.new(opts[:keychain], opts).add(key)
else
key
end
end
|
64
65
66
|
# File 'lib/sym/app/commands/base_command.rb', line 64
def content
@content ||= (opts[:string] || (opts[:file].eql?('-') ? stdin.read : ::File.read(opts[:file]).chomp))
end
|
#create_key ⇒ Object
72
73
74
|
# File 'lib/sym/app/commands/base_command.rb', line 72
def create_key
self.class.create_private_key
end
|
#encrypt_with_password(key) ⇒ Object
84
85
86
87
|
# File 'lib/sym/app/commands/base_command.rb', line 84
def encrypt_with_password(key)
password = application.input_handler.new_password
return encr_password(key, password), password
end
|
68
69
70
|
# File 'lib/sym/app/commands/base_command.rb', line 68
def to_s
"#{self.class.short_name.to_s.bold.yellow}, with options: #{application.args.argv.join(' ').gsub(/--/, '').bold.green}"
end
|