From caa62f166958ef3669e1bdfa48072fbe6a6d54b1 Mon Sep 17 00:00:00 2001 From: gazazello Date: Sun, 27 Jul 2014 13:22:05 -0700 Subject: [PATCH] added hiding password while typing --- examples/.metaforce.yml | 2 ++ lib/metaforce/cli.rb | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/.metaforce.yml b/examples/.metaforce.yml index 6a5773f..5602283 100644 --- a/examples/.metaforce.yml +++ b/examples/.metaforce.yml @@ -1,4 +1,6 @@ # This is purely an example. +# It is a good practice to leave passwords empty in this file and manually type it when prompted. +# Your password will NOT be shown in console while typing. --- production: username: foo@bar.com diff --git a/lib/metaforce/cli.rb b/lib/metaforce/cli.rb index b2e99c0..73160b9 100644 --- a/lib/metaforce/cli.rb +++ b/lib/metaforce/cli.rb @@ -107,7 +107,11 @@ def client credentials.merge!(options.slice(:username, :password, :security_token, :host)) credentials.tap do |credentials| credentials[:username] ||= ask('username:') - credentials[:password] ||= ask('password:') + if credentials[:password].nil? + print("password: ") + credentials[:password] = STDIN.noecho(&:gets).chomp + puts(); + end credentials[:security_token] ||= ask('security token:') end Metaforce.configuration.host = credentials[:host]