Class: MGit::Forall
Overview
eg: mgit forall -c ‘git status’
Constant Summary
collapse
- OPT_LIST =
{
:command => '--command',
:command_s => '-c',
:concurrent => '--concurrent',
:concurrent_s => '-n',
}.freeze
Constants inherited
from BaseCommand
BaseCommand::HIGH_PRIORITY_OPT_LIST, BaseCommand::SELECTABLE_OPT_LIST
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseCommand
#all_repos, cmd, #exec_light_repos, #generate_config_repo, inherited, #initialize, #locked_repos, #run
Class Method Details
.description ⇒ Object
71
72
73
|
# File 'lib/m-git/command/forall.rb', line 71
def self.description
"对多仓库批量执行指令。"
end
|
.usage ⇒ Object
75
76
77
|
# File 'lib/m-git/command/forall.rb', line 75
def self.usage
"mgit forall -c '<instruction>' [(-m|-e) <repo>...] [-n] [-h]"
end
|
Instance Method Details
#enable_repo_selection ⇒ Object
63
64
65
|
# File 'lib/m-git/command/forall.rb', line 63
def enable_repo_selection
true
end
|
#enable_short_basic_option ⇒ Object
67
68
69
|
# File 'lib/m-git/command/forall.rb', line 67
def enable_short_basic_option
true
end
|
#options ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/m-git/command/forall.rb', line 18
def options
return [
ARGV::Opt.new(OPT_LIST[:command],
short_key:OPT_LIST[:command_s],
info:'必须参数,指定需要执行的shell命令,如:"mgit forall -c \'git status -s\'"(注意要带引号)。',
type: :string),
ARGV::Opt.new(OPT_LIST[:concurrent],
short_key:OPT_LIST[:concurrent_s],
info:'可选参数,若指定,则shell命令以多线程方式执行。',
type: :boolean)
].concat(super)
end
|
#validate(argv) ⇒ Object
31
32
33
34
|
# File 'lib/m-git/command/forall.rb', line 31
def validate(argv)
Foundation.help!("输入非法参数:#{argv.git_opts}。请通过\"mgit #{argv.cmd} --help\"查看用法。") if argv.git_opts.length > 0
Foundation.help!("请输入必须参数--command,示例:mgit forall -c 'git status'") if argv.opt(OPT_LIST[:command]).nil?
end
|