34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/modulesync/cli.rb', line 34
def parse_opts(args)
@options = defaults
@options.merge!(Hash.transform_keys_to_symbols(Util.parse_config(MODULESYNC_CONF_FILE)))
@options[:command] = args[0] if commands_available.include?(args[0])
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: msync update [-m <commit message>] [-c <directory> ] [--offline] [--noop] [--bump] [--changelog] [--tag] [--tag-pattern <tag_pattern>] [-p <project_root> [-n <namespace>] [-b <branch>] [-r <branch>] [-f <filter>] | hook activate|deactivate [-c <directory> ] [-n <namespace>] [-b <branch>]"
opts.on('-m', '--message <msg>',
'Commit message to apply to updated modules') do |msg|
@options[:message] = msg
end
opts.on('-n', '--namespace <url>',
'Remote github namespace (user or organization) to clone from and push to. Defaults to puppetlabs') do |namespace|
@options[:namespace] = namespace
end
opts.on('-c', '--configs <directory>',
'The local directory or remote repository to define the list of managed modules, the file templates, and the default values for template variables.') do |configs|
@options[:configs] = configs
end
opts.on('-b', '--branch <branch>',
'Branch name to make the changes in. Defaults to "master"') do |branch|
@options[:branch] = branch
end
opts.on('-p', '--project-root <path>',
'Path used by git to clone modules into. Defaults to "modules"') do |project_root|
@options[:project_root] = project_root
end
opts.on('-r', '--remote-branch <branch>',
'Remote branch name to push the changes to. Defaults to the branch name') do |branch|
@options[:remote_branch] = branch
end
opts.on('-f', '--filter <filter>',
'A regular expression to filter repositories to update.') do |filter|
@options[:filter] = filter
end
opts.on('--amend',
'Amend previous commit') do |msg|
@options[:amend] = true
end
opts.on('--force',
'Force push amended commit') do |msg|
@options[:force] = true
end
opts.on('--noop',
'No-op mode') do |msg|
@options[:noop] = true
end
opts.on('--offline',
'Do not run git command. Helpful if you have existing repositories locally.') do |msg|
@options[:offline] = true
end
opts.on('--bump',
'Bump module version to the next minor') do |msg|
@options[:bump] = true
end
opts.on('--changelog',
'Update CHANGELOG.md if version was bumped') do |msg|
@options[:changelog] = true
end
opts.on('--tag',
'Git tag with the current module version') do |msg|
@options[:tag] = true
end
opts.on('--tag-pattern',
'The pattern to use when tagging releases.') do |pattern|
@options[:tag_pattern] = pattern
end
@options[:help] = opts.help
end.parse!
@options.fetch(:message) do
if @options[:command] == 'update' && ! @options[:noop] && ! @options[:amend] && ! @options[:offline]
fail("A commit message is required unless using noop or offline.")
end
end
@options.fetch(:command) do
fail("A command is required.")
end
if @options[:command] == 'hook' &&
(! args.include?('activate') && ! args.include?('deactivate'))
fail("You must activate or deactivate the hook.")
end
end
|