def self.set_opts(action, optsParser, opts)
opts[:base_ver] = 0
opts[:version] = /.*/
opts[:commits] = []
opts[:do_merge] = false
opts[:push_force] = false
opts[:no_travis] = false
opts[:all] = false
opts[:check_only] = false
opts[:no_fetch] = false
opts[:watch] = false
optsParser.on("-v", "--base-version [MIN_VER]", Integer, "Older release to consider.") {
|val| opts[:base_ver] = val}
optsParser.on("-V", "--version [regexp]", Regexp, "Regexp to filter versions.") {
|val| opts[:version] = val}
if ALL_BRANCHES_ACTIONS.index(action) == nil &&
action != :merge &&
action != :delete then
optsParser.on("-B", "--manual-branch <branch name>", "Work on a specific (non-stable) branch.") {
|val| opts[:manual_branch] = val}
end
if NO_FETCH_ACTIONS.index(action) == nil
optsParser.on("--no-fetch", "Skip fetch of stable repo.") {
|val| opts[:no_fetch] = true}
end
case action
when :cp
optsParser.banner += "-c <sha1> [-c <sha1> ...]"
optsParser.on("-c", "--sha1 [SHA1]", String, "Commit to cherry-pick. Can be used multiple time.") {
|val| opts[:commits] << val}
when :merge
optsParser.banner += "-m <suffix>"
optsParser.on("-m", "--merge [SUFFIX]", "Merge branch with suffix.") {
|val| opts[:do_merge] = val}
when :monitor, :monitor_stable
optsParser.on("-w", "--watch <PERIOD>", Integer,
"Watch and refresh travis status every <PERIOD>.") {
|val| opts[:watch] = val}
when :push
optsParser.banner += "[-f]"
optsParser.on("-f", "--force", "Add --force to git push (for 'push' action).") {
|val| opts[:push_force] = val}
when :push_stable
optsParser.banner += "[-T]"
optsParser.on("-T", "--no-travis", "Ignore Travis build status and push anyway.") {
|val| opts[:no_travis] = true}
optsParser.on("-c", "--check", "Check if there is something to be pushed.") {
|val| opts[:check_only] = true}
when :steal
optsParser.banner += "[-a]"
optsParser.on("-a", "--all", "Check all commits from master. "+
"By default only new commits (since last successful run) are considered.") {
|val| opts[:all] = true}
end
end