Module: OptionalOptions

Included in:
OptParserInternal
Defined in:
lib/gitarro/opt_parser.rb

Overview

this are the optional options

Instance Method Summary collapse

Instance Method Details

#branch_opt(opt) ⇒ Object



56
57
58
59
60
61
# File 'lib/gitarro/opt_parser.rb', line 56

def branch_opt(opt)
  desc = 'run tests only if the pr target the upstream branch specified'
  opt.on('-b', "--branch 'GITHUB BRANCH'", desc) do |b|
    @options[:branch] = b
  end
end

#changed_since(opt) ⇒ Object



101
102
103
104
105
106
107
108
# File 'lib/gitarro/opt_parser.rb', line 101

def changed_since(opt)
  changed_since_desc = 'If present, will only check PRs with a ' \
                     'change in the last X seconds'
  opt.on("--changed_since 'SECONDS'",
         changed_since_desc) do |changed_since|
    @options[:changed_since] = Integer(changed_since)
  end
end

#check_opt(opt) ⇒ Object



35
36
37
38
# File 'lib/gitarro/opt_parser.rb', line 35

def check_opt(opt)
  desc = 'Check if there is any PR requiring a test, but do not run it.'
  opt.on('-C', '--check', desc) { |check| @options[:check] = check }
end

#desc_opt(opt) ⇒ Object



50
51
52
53
54
# File 'lib/gitarro/opt_parser.rb', line 50

def desc_opt(opt)
  opt.on('-d', "--description 'DESCRIPTION'", 'Test decription') do |d|
    @options[:description] = d
  end
end

#file_opt(opt) ⇒ Object



80
81
82
83
84
85
# File 'lib/gitarro/opt_parser.rb', line 80

def file_opt(opt)
  file_description = 'pr_file type to run the test against: .py, .rb'
  opt.on('-f', "--file \'.py\'", file_description) do |file_type|
    @options[:file_type] = file_type
  end
end

#force_test_opt(opt) ⇒ Object



40
41
42
43
# File 'lib/gitarro/opt_parser.rb', line 40

def force_test_opt(opt)
  desc = 'Force to run a test, even if is not marked to be re-triggered.'
  opt.on('-F', '--force_test', desc) { |force_test| @options[:force_test] = force_test }
end

#git_opt(opt) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/gitarro/opt_parser.rb', line 63

def git_opt(opt)
  desc = 'Specify a location where gitarro will clone the GitHub project. '\
         'If the dir does not exists, gitarro will create one. '\
         'by default is the /tmp'
  opt.on('-g', "--git_dir 'GIT_LOCAL_DIR'", desc) do |git_dir|
    @options[:git_dir] = git_dir
  end
end

#https_opt(opt) ⇒ Object



87
88
89
90
# File 'lib/gitarro/opt_parser.rb', line 87

def https_opt(opt)
  https_desc = 'If present, use https instead of ssh for git operations'
  opt.on('--https', https_desc) { |https| @options[:https] = https }
end

#no_shallow(opt) ⇒ Object



45
46
47
48
# File 'lib/gitarro/opt_parser.rb', line 45

def no_shallow(opt)
  desc = 'If enabled, gitarro will not use git shallow clone'
  opt.on('--noshallow', desc) { |noshallow| @options[:noshallow] = noshallow }
end

#optional_options(opt) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/gitarro/opt_parser.rb', line 110

def optional_options(opt)
  opt.separator "\n Optional options:"
  desc_opt(opt)
  check_opt(opt)
  force_test_opt(opt)
  branch_opt(opt)
  no_shallow(opt)
  file_opt(opt)
  url_opt(opt)
  pr_number(opt)
  https_opt(opt)
  changed_since(opt)
  git_opt(opt)
end

#pr_number(opt) ⇒ Object



92
93
94
95
96
97
98
99
# File 'lib/gitarro/opt_parser.rb', line 92

def pr_number(opt)
  desc = 'Specify the PR number instead of checking all of them. ' \
         'Force to rerun against a specific PR number,' \
         'even if it is not needed.'
  opt.on('-P', "--PR 'NUMBER'", desc) do |pr_number|
    @options[:pr_number] = pr_number.to_i
  end
end

#url_opt(opt) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/gitarro/opt_parser.rb', line 72

def url_opt(opt)
  desc = 'Specify the URL to append to add to the GitHub review. ' \
         'Usually you will use an URL to the Jenkins build log.'
  opt.on('-u', "--url 'TARGET_URL'", desc) do |target_url|
    @options[:target_url] = target_url
  end
end