From dd9e6312e222c2fe836b095c6163ecc392122cab Mon Sep 17 00:00:00 2001 From: Guillaume Dott Date: Wed, 22 Oct 2014 10:41:15 +0200 Subject: [PATCH] Use ENV['MASTER_KEY'] if defined --- lib/twik/cli.rb | 11 +---------- lib/twik/cli/config.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 10 deletions(-) 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