diff --git a/lib/twik/cli.rb b/lib/twik/cli.rb index 9ff4b50..c59640e 100644 --- a/lib/twik/cli.rb +++ b/lib/twik/cli.rb @@ -15,16 +15,7 @@ class Twik end def run - masterkey = ask('Master key: ') - puts twik.generate(config.tag, masterkey) - end - - def ask(prompt) - print prompt - res = STDIN.noecho(&:gets).chomp - puts - - res + puts twik.generate(config.tag, config.masterkey) end end end diff --git a/lib/twik/cli/config.rb b/lib/twik/cli/config.rb index f542d40..48d2199 100644 --- a/lib/twik/cli/config.rb +++ b/lib/twik/cli/config.rb @@ -28,6 +28,18 @@ class Twik @yaml = YAML.load_file(file.path) end + def ask(prompt) + print prompt + res = STDIN.noecho(&:gets).chomp + puts + + res + end + + def masterkey + ENV['MASTER_KEY'] || ask('Master key: ') + end + def profile args['profile'] || 'default' end