Skip to content

Commit

Permalink
[Bug] Fixes #50 - Deal with stdin errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeloupy committed Nov 2, 2015
1 parent b301271 commit 103c9f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
/tmp/
tags
gems.tags
.DS_Store
13 changes: 13 additions & 0 deletions bin/checklister
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,25 @@ command :new do |c|
puts "* Type some letters of your project's name..."
project_like = STDIN.gets.chomp
projects = project_client.filtered_by_name(project_like)

while projects.empty?
puts "* We couldn't find any project matching your request. Please be more specific, and make sure that the project exists."
project_like = STDIN.gets.chomp
projects = project_client.filtered_by_name(project_like)
end

default_project_id = projects.first[:id]
projects.each_with_index do |project, index|
puts "%-5s %-100s" % ["[#{index}]", project[:name]]
end
puts "* Pick your project, defaults to [0]"
choice = STDIN.gets.chomp

while !(0...projects.size).to_a.include?(choice.to_i)
puts "* You need to select a project from this list. Please choose again."
choice = STDIN.gets.chomp
end

project_id = choice == "" ? default_project_id : projects[choice.to_i][:id]
project = project_client.get(project_id)
puts "* Creating a checklist issue from #{checklist_path}"
Expand Down

0 comments on commit 103c9f2

Please sign in to comment.