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

#changed_since(opt) ⇒ Object



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

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



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



94
95
96
97
98
99
100
101
102
103
# File 'lib/gitarro/opt_parser.rb', line 94

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

#pr_number(opt) ⇒ Object



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

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