Permalink
Browse files

change cmd line utility to just take a template file

Instead of having the API token as a cmd line argument and ending up
in history, the API token and project ID are now specified in the yml
along with the stories.
  • Loading branch information...
1 parent 928f5cb commit bfd3d9c9cb8909fef55af1e78d24d9c88ba712a5 @vinbarnes committed Feb 14, 2012
Showing with 12 additions and 22 deletions.
  1. +12 −22 bin/tp
View
34 bin/tp
@@ -1,33 +1,23 @@
#!/usr/bin/env ruby
require 'pivotal-tracker'
-require 'optparse'
-options = {}
-OptionParser.new do |opts|
- opts.program_name = 'tp'
- opts.banner = "Usage: tp [options]"
- opts.on("--token TOKEN",
- "Pivotal Tracker token") do |token|
- options[:token] = token
- end
- opts.on("--project PROJECT_ID",
- "Pivotal Tracker project id") do |project|
- options[:project] = project
- end
- opts.on("--file TEMPLATE_FILE",
- "YAML template file containing stories") do |file|
- options[:file] = file
- end
-end.parse(ARGV)
+def usage
+ <<-HELP
+Usage: tp template_file
+ --help you're looking at it
+HELP
+end
-PivotalTracker::Client.token = options[:token]
+abort usage if ARGV.empty? or ARGV.first == '--help'
-templates = YAML::load(File.read(options[:file]))
+file = YAML::load(File.read(ARGV.first))
-project = PivotalTracker::Project.find(options[:project])
+PivotalTracker::Client.token = file[:token]
+
+project = PivotalTracker::Project.find(file[:project])
puts "Packing..."
-ids = templates.map {|story| project.stories.create(story).id }
+ids = file[:stories].map {|story| project.stories.create(story).id }
puts "Stories created: "
puts ids

0 comments on commit bfd3d9c

Please sign in to comment.