require 'thor' require_relative 'dngg/version' require_relative 'dngg/command/start' require_relative 'dngg/command/sync' require_relative 'dngg/command/switch' require_relative 'dngg/command/delete' require_relative 'dngg/command/foreach' require_relative 'dngg/command/merge' require_relative 'dngg/command/finish' require_relative 'dngg/command/mr' module DNGG class Cli < Thor include Start include Sync include Switch include Delete include Foreach include Merge include Finish include MR def self.exit_on_failure? true end desc 'sync', '当前分支同步(拉取)远程代码' def sync sync_flow end desc 'start [] []', '检出新分支,新功能、修bug务必使用该命令' def start(branch, action='') start_flow(branch, action) end desc 'merge ', 'Merge,开发完成后执行' # option :rebase, :default => false, :type => :boolean, aliases: '-r' def merge(branch) rebase = options[:rebase] merge_flow(branch, rebase) end desc 'finish [-f|--force]', 'Merge后并解决冲突后执行; -f:主工程强制推送' option :force, :default => false, :type => :boolean, aliases: '-f' def finish force = options[:force] finish_flow(force) end desc 'mr ', '创建MR' def mr(branch, title) mr_flow(branch, title) end desc 'switch <branch>', '切换分支' def switch(branch) switch_flow(branch) end desc 'delete <branch> [-r|--remote] [-a|--all]', '删除指定分支' option :remote, :default => false, :type => :boolean, aliases: '-r' option :all, :default => false, :type => :boolean, aliases: '-a' def delete(branch) remote = options[:remote] all = options[:all] delete_flow(branch, remote, all) end desc 'foreach [<commands>...]', '所有模块执行git命令(foreach后跟git命令)' def foreach(*commands) foreach_flow(*commands) end desc 'v', '查看版本' def version puts VERSION end end end