#!/usr/bin/env ruby # vim: syn=ruby $: << 'lib' 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]" options[:roadmap] = 'ROADMAP' # the roadmap file opts.on('-r ROADMAP_FILE', '--roadmap 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| 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| 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 options[:verbose] = true end opts.on_tail('-h', '--help', 'Display this screen') do puts opts exit end end optparse.parse!(ARGV) # determine the command command = ARGV[0] || 'info' cmd_alias = {'pg' => 'progress', 'update-roadmap' => 'ur', 'clean' => 'cleanup'} command = cmd_alias[command] if cmd_alias[command] if %w[info init complete progress close release ur update-roadmap cleanup clean].include? command options[:command] = command else 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 unless command == 'init' unless File.exists? (options[:local_config]) puts "Initializing your environment ... " DevFlow.invoke!(options, 'init') end end if command == 'release' options[:release] = true command = 'close' end DevFlow.invoke!(options, command)