require 'thor' require_relative 'ggsm/version' require_relative 'ggsm/command/start' require_relative 'ggsm/command/sync' require_relative 'ggsm/command/switch' require_relative 'ggsm/command/delete' require_relative 'ggsm/command/foreach' require_relative 'ggsm/command/merge' require_relative 'ggsm/command/finish' module GGSM class Cli < Thor include Start include Sync include Switch include Delete include Foreach include Merge include Finish desc 'sync', '当前分支同步(拉取)远程代码' def sync sync_flow end desc 'start [] []', '检出新分支,新功能、修bug务必使用该命令' def start(branch, action='') start_flow(branch, action) end desc 'merge [-r|--rebase]', 'Merge,开发完成后执行; --rebase:主工程强制rebase' option :can_rebase, :default => false, :type => :boolean, aliases: '-r' def merge(branch) rebase = options[:can_rebase] merge_flow(branch, rebase) end desc 'finish [-f|--force]', 'Merge后并解决冲突后执行; --force:主工程强制推送' option :force, :default => false, :type => :boolean, aliases: '-f' def finish force = options[:force] finish_flow(force) end desc 'switch ', '切换分支' def switch(branch) switch_flow(branch) end desc 'delete [-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 'status', '显示所有模块的状态' def status foreach('status') end desc 'foreach [...]', '所有模块执行git命令(foreach后跟git命令)' def foreach(*commands) foreach_flow(*commands) end desc 'v|version', '查看版本' def version puts VERSION end end end