-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_request.rb
More file actions
executable file
·56 lines (39 loc) · 1.64 KB
/
generate_request.rb
File metadata and controls
executable file
·56 lines (39 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env ruby
require "optparse"
require_relative "lib/load_config"
require_relative "lib/render_template"
helpme = ARGV.empty? ? true : false
options = {
query: "default",
config: "config.yaml",
project: 11600,
issuetype: 3
}
oparser = OptionParser.new do |opts|
opts.on("-h", "--help", "show this help")
opts.on("-q", "--query STR", String, "query template to use [name] (default: \"default\")")
opts.on("-c", "--config STR", String, "config file to use [path] (default: \"config.yaml\")")
opts.on("-p", "--project STR", String, "project to create task in [id] (default: 11600)")
opts.on("-i", "--issuetype INT", Integer, "issue type for the task to use [id] (default: 3)")
opts.on("-t", "--tool STR", String, "tool name [name]")
opts.on("-v", "--version STR", String, "tool version string [version]")
opts.on("-r", "--release", "create a release task (default: false)")
opts.on("-d", "--description [STR]", String, "task description [text] (don't pass a description to clear config setting)")
opts.on("-u", "--url [STR]", String, "release notes/news page/changelog/... address [url] (don't pass a url to clear config setting)")
end
oparser.parse!(into: options)
if helpme || options[:help]
puts oparser
exit 1
end
unless options.has_key?(:tool)
puts "ERROR: option [-t|--tool] is required"
exit 1
end
unless options.has_key?(:version)
puts "ERROR: option [-v|--version] is required"
exit 1
end
yaml = load_config(options[:config])
toolconfig = yaml[options[:tool].to_sym].to_h.merge(options.reject{|key, value| [:help, :query, :config].include?(key)}).compact
puts "{%s}" % render_template("qry_%s" % options[:query], toolconfig)