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.
55
56
57
|
# File 'lib/sym/app/commands/base_command.rb', line 55
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
89
90
91
|
# File 'lib/sym/app/commands/base_command.rb', line 89
def add_password_to_the_cache(encrypted_key, password)
self.application.password_cache[encrypted_key] = password
end
|
#add_to_keychain_if_needed(key) ⇒ Object
75
76
77
78
79
80
81
|
# File 'lib/sym/app/commands/base_command.rb', line 75
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
|
63
64
65
|
# File 'lib/sym/app/commands/base_command.rb', line 63
def content
@content ||= (opts[:string] || (opts[:file].eql?('-') ? stdin.read : ::File.read(opts[:file]).chomp))
end
|
#create_key ⇒ Object
71
72
73
|
# File 'lib/sym/app/commands/base_command.rb', line 71
def create_key
self.class.create_private_key
end
|
#encrypt_with_password(key) ⇒ Object
83
84
85
86
|
# File 'lib/sym/app/commands/base_command.rb', line 83
def encrypt_with_password(key)
password = application.input_handler.new_password
return encr_password(key, password), password
end
|
67
68
69
|
# File 'lib/sym/app/commands/base_command.rb', line 67
def to_s
"#{self.class.short_name.to_s.bold.yellow}, with options: #{application.args.argv.join(' ').gsub(/--/, '').bold.green}"
end
|