Skip to content

Commit

Permalink
Initial implementation, with broken test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Shearar committed Jun 22, 2013
1 parent f42b843 commit 29e7687
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions Gemfile
@@ -1,4 +1,5 @@
source 'http://rubygems.org'
gem 'highline'
gem 'json', '~> 1.7.7'
gem 'octokit'
gem 'rake'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -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)
Expand Down Expand Up @@ -84,6 +85,7 @@ DEPENDENCIES
coveralls
guard-rspec
hamsterdam
highline
json (~> 1.7.7)
octokit
pry
Expand Down
8 changes: 7 additions & 1 deletion lib/octoherder/cli.rb
@@ -1,4 +1,5 @@
require 'octoherder'
require 'highline'
require 'trollop'


Expand All @@ -11,7 +12,7 @@ def self.parse_argv(args)
OctoHerder helps you manage your multi-repository project.
Usage:
octoherder [options]
where [options] are:
HELP
Expand All @@ -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
Expand Down
14 changes: 13 additions & 1 deletion spec/cli_spec.rb
Expand Up @@ -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 <filename/uri>: Path to the canonical project setup
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 29e7687

Please sign in to comment.