diff --git a/Gemfile b/Gemfile index e3e237c..d3b4e57 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,5 @@ source 'http://rubygems.org' +gem 'highline' gem 'json', '~> 1.7.7' gem 'octokit' gem 'rake' diff --git a/Gemfile.lock b/Gemfile.lock index 6601560..8cef08e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,6 +30,7 @@ GEM hamsterdam (1.0.8) hamster hashie (2.0.5) + highline (1.6.19) json (1.7.7) listen (1.1.4) rb-fsevent (>= 0.9.3) @@ -84,6 +85,7 @@ DEPENDENCIES coveralls guard-rspec hamsterdam + highline json (~> 1.7.7) octokit pry diff --git a/lib/octoherder/cli.rb b/lib/octoherder/cli.rb index ca7ac4a..3f36427 100644 --- a/lib/octoherder/cli.rb +++ b/lib/octoherder/cli.rb @@ -1,4 +1,5 @@ require 'octoherder' +require 'highline' require 'trollop' @@ -11,7 +12,7 @@ def self.parse_argv(args) OctoHerder helps you manage your multi-repository project. Usage: - + octoherder [options] where [options] are: HELP @@ -36,6 +37,11 @@ def self.parse_argv(args) def self.run(args) opts = parse_argv(args) + if ! opts[:password_given] then + opts[:password_given] = true + opts[:password] = HighLine.new.ask("Enter password: ") { |q| q.echo = false } + end + kitty = Octokit.new(octoauth(opts)) CLI.new.run kitty, opts end diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 89c49f9..c3e979c 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -18,7 +18,7 @@ def run(args, octokit_connection) OctoHerder helps you manage your multi-repository project. Usage: - + octoherder [options] where [options] are: --input-file, -i : Path to the canonical project setup @@ -125,6 +125,18 @@ def run(args, octokit_connection) kitty.should_receive(:password).with(password) run(["--user", "me", "--password", password], kitty) end + + it "will prompt for a password if none given" do + orig_stdin = $stdin + begin + $stdin = StringIO.new("1234") + run(["--user", "me"], kitty) + expect($stdout.readline).to include("Password") + $stdin.puts(password) + ensure + $stdin = orig_stdin + end + end end end