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

#cachehttp_opt(opt) ⇒ Object



76
77
78
79
80
81
82
# File 'lib/gitarro/opt_parser.rb', line 76

def cachehttp_opt(opt)
  desc = 'Custom path where http cache for gitarro is stored' \
         'by default is set to /tmp/gitarro/httpcache'
  opt.on('-k', "--cachepath 'CACHEPATH'", desc) do |cache_http|
    @options[:cachehttp] = cache_http
  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

#changelog_opt(opt) ⇒ Object



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

def changelog_opt(opt)
  desc = 'Check if the PR includes a changelog entry ' \
         '(Automatically sets --file ".changes").'
  opt.on('--changelogtest', desc) do |changelogtest|
    @options[:changelog_test] = changelogtest
  end
end

#check_opt(opt) ⇒ Object



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

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



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

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

#https_opt(opt) ⇒ Object



71
72
73
74
# File 'lib/gitarro/opt_parser.rb', line 71

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

#optional_options(opt) ⇒ Object



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

def optional_options(opt)
  opt.separator "\n Optional options:"
  desc_opt(opt)
  check_opt(opt)
  file_opt(opt)
  changelog_opt(opt)
  url_opt(opt)
  pr_number(opt)
  https_opt(opt)
  cachehttp_opt(opt)
  changed_since(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] = Integer(pr_number)
  end
end

#url_opt(opt) ⇒ Object



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

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