Add config for default profile

master
Guillaume Dott 2014-10-22 10:41:53 +02:00
parent dd9e6312e2
commit e036d32744
2 changed files with 5 additions and 4 deletions

View File

@ -10,6 +10,7 @@ class Twik
def self.default def self.default
{ {
'default_profile' => 'default',
'profiles' => { 'profiles' => {
'default' => { 'default' => {
'privatekey' => Twik::PrivateKey.generate, 'privatekey' => Twik::PrivateKey.generate,
@ -41,7 +42,7 @@ class Twik
end end
def profile def profile
args['profile'] || 'default' args['profile'] || yaml['default_profile'] || 'default'
end end
def options def options

View File

@ -12,16 +12,16 @@ class Twik
opts.separator '' opts.separator ''
opts.separator 'Specific options:' opts.separator 'Specific options:'
opts.on('-l', '--length LENGTH', 'length of generated password (4-26). Default: 16') do |length| opts.on('-l', '--length LENGTH', 'length of generated password (4-26)') do |length|
options['length'] = length.to_i options['length'] = length.to_i
end end
opts.on('-p', '--profile PROFILE', "profile to use. Default: 'default'") do |profile| opts.on('-p', '--profile PROFILE', "profile to use") do |profile|
options['profile'] = profile options['profile'] = profile
end end
opts.on('-t', '--type TYPE', Twik::TYPE, opts.on('-t', '--type TYPE', Twik::TYPE,
"type of password:", " #{Twik::TYPE.join(', ')}", " Default: alphanumeric_and_special_chars") do |type| "type of password:", " #{Twik::TYPE.join(', ')}") do |type|
options['type'] = type.to_sym options['type'] = type.to_sym
end end