bin/dw in dev_flow-0.2.4 vs bin/dw in dev_flow-0.3.0
- old
+ new
@@ -1,41 +1,53 @@
#!/usr/bin/env ruby
# vim: syn=ruby
-# $: << 'lib' # debug only
+$: << 'lib' # debug only
require "optparse"
require "term/ansicolor"
class String; include Term::ANSIColor end
require "dev_flow"
options = {}
optparse = OptionParser.new do |opts|
opts.banner = "Usage: dw [options] [command]"
+ opts.separator ""
+ opts.separator "Commands:"
+ opts.separator " [info] : show list of tasks"
+ opts.separator " switch : show list of tasks, and tasks can swith to"
+ opts.separator " switch [branch]: directly switch to a branch"
+ opts.separator " s [branch]: alias of switch"
+ opts.separator " update-roadmap : on develop branch, update the roadmap file"
+ opts.separator " ur : alias of update-roadmap"
+ opts.separator " progress <percentage>: change the task progress to percentage (0-99)"
+ opts.separator " p <percentage> : alias of progress"
+ opts.separator " complete : complete a task, raise progress to 99"
+ opts.separator " close : close the task as a leader"
+ opts.separator " release : close a release task"
+ opts.separator " clean[up] : delete local branches that already completed"
+ opts.separator ""
+ opts.separator "Options:"
options[:roadmap] = 'ROADMAP' # the roadmap file
- opts.on('-r ROADMAP_FILE', '--roadmap ROADMAP_FILE', 'use an other roadmap file') do |roadmap|
+ opts.on('-r FILE', '--roadmap FILE', 'use an other roadmap file') do |roadmap|
options[:roadmap] = roadmap
end
options[:local_config] = '.dev_flow'
- opts.on('-l LOCAL_CONFIG', '--local-config LOCAL_CONFIG', 'use an other local configuration file') do |lc|
+ opts.on('-l FILE', '--local-config FILE', 'use an other local configuration file') do |lc|
options[:local_config] = lc
end
options[:members_file] = 'members.yml' if File.exists? ('members.yml')
options[:members_file] = 'config/members.yml' if File.exists? ('config/members.yml')
- opts.on('-m MEMBERS_FILE', '--members_file MEMBERS_FILE', 'use an other members file') do |mf|
+ opts.on('-m FILE', '--members_file FILE', 'use an other members file') do |mf|
options[:members_file] = mf
raise "the specified members file #{mf} is not exists." unless File.exists? mf
end
- opts.on('-i', '--filter-tasks', 'show only tasks assigned to me') do
- options[:filter_tasks] = true
- end
-
opts.on('-o', '--offline', 'do not use remote git server') do
options[:offline] = true
end
opts.on('-v', '--verbose', 'print more messages') do
@@ -50,26 +62,26 @@
optparse.parse!(ARGV)
# determine the command
command = ARGV[0] || 'info'
-cmd_alias = {'pg' => 'progress', 'update-roadmap' => 'ur', 'clean' => 'cleanup'}
+cmd_alias = {'pg' => 'progress', 'update-roadmap' => 'ur', 'clean' => 'cleanup', 's' => 'switch'}
command = cmd_alias[command] if cmd_alias[command]
-if %w[info init complete progress close release ur update-roadmap cleanup clean].include? command
+if %w[info init complete progress close release ur update-roadmap cleanup clean switch].include? command
options[:command] = command
else
- puts "unknown command #{command}".red
+ puts "Unknown command #{command}".red
exit
end
unless File.exists? (options[:roadmap])
puts "No roadmap file (#{options[:roadmap]}) found, can not continue.".red
exit
end
-# switch to init mode unless .dev_flow file exists
+# enter init mode unless .dev_flow file exists
unless command == 'init'
unless File.exists? (options[:local_config])
puts "Initializing your environment ... "
DevFlow.invoke!(options, 'init')
end
@@ -77,8 +89,14 @@
# release is just a alias of command close buth with a option flag set
if command == 'release'
options[:release] = true
command = 'close'
+end
+
+if command == 'switch'
+ options[:switch] = true
+ options[:branch] = ARGV[1]
+ command = 'info'
end
DevFlow.invoke!(options, command)