bin/pgit in pgit-0.0.4 vs bin/pgit in pgit-1.0.0

- old
+ new

@@ -8,10 +8,17 @@ version Pgit::VERSION subcommand_option_handling :normal arguments :strict +desc "Color output" +default_value :true +switch :color + +desc "Print backtrace if there is an exception" +switch :trace + # desc 'Path to the config file' # default_value "#{ENV['HOME']}/.pgit.rc.yml" # arg_name '/path/to/.pivotal.yml' # flag [:c,:config] @@ -19,15 +26,158 @@ # switch [:force] # desc 'PivotalTracker API Token' # arg_name 'secr3tT0ken123' # flag [:'api-token'] +desc "Work with projects" +command :proj do |p| + p.desc "add a project" + p.command :add do |a| + + a.desc "the id associated to the Pivotal Tracker project" + a.arg_name '12030405' + a.flag :d, :id + + a.desc "the filepath that is going to be associated to the Pivotal Tracker and Git project" + a.arg_name '"/some/file/path"' + a.default_value Dir.pwd + a.flag :p, :path + + a.desc "your Pivotal Tracker API token" + a.arg_name "token" + a.flag :t, :api_token + + a.action do |global_options,options,args| + app = PGit::Project::Application.new(global_options, options, args) + add = PGit::Project::Add.new(app) + add.execute! + end + end + + p.desc "remove a project" + p.command :rm do |a| + + a.desc "the path whose pgit project will be removed" + a.arg_name '"/some/file/path"' + a.default_value Dir.pwd + a.flag :p, :path + + a.action do |global_options,options,args| + app = PGit::Project::Application.new(global_options, options, args) + rm = PGit::Project::Remove.new(app) + rm.execute! + end + end +end + +desc "Work with custom commands defined in the current project" +command :cmd do |c| + c.desc "show the custom command(s)" + c.arg_name 'command_name' + c.command :show do |s| + s.action do |global_options,options,args| + app = PGit::Command::Application.new(global_options, + options, + args) + + show = PGit::Command::Show.new(app) + show.execute! + end + end + + c.desc "run a command" + c.arg_name 'command_name' + c.command :run do |r| + r.action do |global_options,options,args| + app = PGit::Command::Application.new(global_options, + options, + args) + run = PGit::Command::Run.new(app) + run.execute! + end + end + + c.desc "add a command" + c.command :add do |a| + accept(Array) do |value| + value.split(',').map {|item| item.strip } + end + a.desc "name of the command" + a.arg_name "new_command_name" + a.flag :n, :name, required: true + + a.desc "steps of the command, delimited by commas" + a.arg_name "steps" + a.flag :s, :steps, required: true, type: Array + + a.action do |global_options,options,args| + app = PGit::Command::Application.new(global_options, + options, + args) + add = PGit::Command::Add.new(app) + add.execute! + end + end + + c.desc "edit a command" + c.command :edit do |a| + accept(Array) do |value| + value.split(',').map {|item| item.strip } + end + a.desc "name of the command" + a.arg_name "new_command_name" + a.flag :n, :name, required: true + + a.desc "steps of the command, delimited by commas" + a.arg_name "steps" + a.flag :s, :steps, required: true, type: Array + + a.action do |global_options,options,args| + app = PGit::Command::Application.new(global_options, + options, + args) + edit = PGit::Command::Edit.new(app) + edit.execute! + end + end + + c.desc "remove a command" + c.command :rm do |a| + accept(Array) do |value| + value.split(',').map {|item| item.strip } + end + a.desc "name of the command" + a.arg_name "new_command_name" + a.flag :n, :name, required: true + + a.action do |global_options,options,args| + app = PGit::Command::Application.new(global_options, + options, + args) + remove = PGit::Command::Remove.new(app) + remove.execute! + end + end +end + +desc "Show the status of the story being worked on" +command :status do |c| + c.action do |global_options,options,args| + status = PGit::Status.new(global_options,options,args) + status.execute! + end +end + desc "Installs the pgit configuration file" command :install do |c| c.action do |global_options,options,args| - PGit::Installer::Configuration.new(global_options, options, args) + completer = PGit::Installer::BashAutoCompletion.new(global_options, + options, + args) + completer.write_completer_file + completer.source_completer_from_bashrc end end # desc 'Start, finish, etc. Pivotal Tracker story branches' desc 'Start Pivotal Tracker story branches' @@ -39,48 +189,38 @@ c.desc "Parses the title of the given Pivotal Tracker story,\n" + " makes the branch name, and does a checkout" c.arg_name 'STORY_ID' c.flag :s, :start - # c.desc "Merge back to staging, remove local and remote (origin?) branches" - # c.switch :f, :finish - - # c.desc "Attempts to join the story-branch that, presumably, already exists" - # c.arg_name 'STORY_ID' - # c.flag :j, :join - c.action do |global_options,options,args| PGit::StoryBranch::Application.new(global_options, options, args) end end -# desc 'Wraps `git commit -m` and prepends the message with story id of the branch' +desc 'Deal with iterations' -# command :commit do |c| - # arg_name 'Describe arguments to commit here' - # c.action do |global_options,options,args| - # puts "commit command ran" - # end -# end - - +command :branch do |c| + c.desc "The scope of the iteration. Valid scopes are 'current', 'current_backlog', 'backlog', and 'done'" + c.default_value :current_backlog + c.flag :s, :scope + c.action do |global_options,options,args| + bilateral_story = PGit::Bilateral::Story.new(options) + bilateral_story.execute! + end +end desc 'Initializes configuration file' - arg_name 'path/to/config_file' -# command :init_config do |c| - # c.action do |global_options,options,args| - # puts "init_config command ran" - # end -# end - pre do |global,command,options,args| # Pre logic here # Return true to proceed; false to abort and not call the # chosen command # Use skips_pre before a command to skip this block # on that command only + # $trace = true if global.fetch(:trace) + $trace = true if global.fetch(:trace) + Rainbow.enabled = global.fetch(:color) true end post do |global,command,options,args| # Post logic here @@ -89,9 +229,11 @@ end on_error do |exception| # Error logic here # return false to skip default error handling - true + warn Rainbow("error: #{exception}").color(:red) + exception.backtrace.each { |e| warn Rainbow(e).color(:red) } if $trace + exit 1 end exit run(ARGV)