@@ -1,13 +1,51 | |||
|
1 | 1 | #!/usr/bin/ruby |
|
2 | 2 | |
|
3 | # rdm-mailhandler | |
|
3 | # == Synopsis | |
|
4 | # | |
|
4 | 5 | # Reads an email from standard input and forward it to a Redmine server |
|
5 | # Can be used from a remote mail server | |
|
6 | # through a HTTP request. | |
|
7 | # | |
|
8 | # == Usage | |
|
9 | # | |
|
10 | # rdm-mailhandler [options] --url=<Redmine URL> --key=<API key> | |
|
11 | # | |
|
12 | # == Arguments | |
|
13 | # | |
|
14 | # -u, --url URL of the Redmine server | |
|
15 | # -k, --key Redmine API key | |
|
16 | # | |
|
17 | # General options: | |
|
18 | # -h, --help show this help | |
|
19 | # -v, --verbose show extra information | |
|
20 | # -V, --version show version information and exit | |
|
21 | # | |
|
22 | # Issue attributes control options: | |
|
23 | # -p, --project=PROJECT identifier of the target project | |
|
24 | # -t, --tracker=TRACKER name of the target tracker | |
|
25 | # --category=CATEGORY name of the target category | |
|
26 | # --priority=PRIORITY name of the target priority | |
|
27 | # -o, --allow-override=ATTRS allow email content to override attributes | |
|
28 | # specified by previous options | |
|
29 | # ATTRS is a comma separated list of attributes | |
|
30 | # | |
|
31 | # == Examples | |
|
32 | # No project specified. Emails MUST contain the 'Project' keyword: | |
|
33 | # | |
|
34 | # rdm-mailhandler --url http://redmine.domain.foo --key secret | |
|
35 | # | |
|
36 | # Fixed project and default tracker specified, but emails can override | |
|
37 | # both tracker and priority attributes using keywords: | |
|
38 | # | |
|
39 | # rdm-mailhandler --url https://domain.foo/redmine --key secret \\ | |
|
40 | # --project foo \\ | |
|
41 | # --tracker bug \\ | |
|
42 | # --allow-override tracker,priority | |
|
6 | 43 | |
|
7 | 44 | require 'net/http' |
|
8 | 45 | require 'net/https' |
|
9 | 46 | require 'uri' |
|
10 | 47 | require 'getoptlong' |
|
48 | require 'rdoc/usage' | |
|
11 | 49 | |
|
12 | 50 | module Net |
|
13 | 51 | class HTTPS < HTTP |
@@ -62,7 +100,7 class RedmineMailHandler | |||
|
62 | 100 | end |
|
63 | 101 | end |
|
64 | 102 | |
|
65 | usage if url.nil? | |
|
103 | RDoc.usage if url.nil? | |
|
66 | 104 | end |
|
67 | 105 | |
|
68 | 106 | def submit(email) |
@@ -79,43 +117,6 class RedmineMailHandler | |||
|
79 | 117 | |
|
80 | 118 | private |
|
81 | 119 | |
|
82 | def usage | |
|
83 | puts <<-USAGE | |
|
84 | Usage: rdm-mailhandler [options] --url=<Redmine URL> --key=<API key> | |
|
85 | Reads an email from standard input and forward it to a Redmine server | |
|
86 | ||
|
87 | Required: | |
|
88 | -u, --url URL of the Redmine server | |
|
89 | -k, --key Redmine API key | |
|
90 | ||
|
91 | General options: | |
|
92 | -h, --help show this help | |
|
93 | -v, --verbose show extra information | |
|
94 | -V, --version show version information and exit | |
|
95 | ||
|
96 | Issue attributes control options: | |
|
97 | -p, --project=PROJECT identifier of the target project | |
|
98 | -t, --tracker=TRACKER name of the target tracker | |
|
99 | --category=CATEGORY name of the target category | |
|
100 | --priority=PRIORITY name of the target priority | |
|
101 | -o, --allow-override=ATTRS allow email content to override attributes | |
|
102 | specified by previous options | |
|
103 | ATTRS is a comma separated list of attributes | |
|
104 | ||
|
105 | Examples: | |
|
106 | # No project specified. Emails MUST contain the 'Project' keyword: | |
|
107 | rdm-mailhandler --url http://redmine.domain.foo --key secret | |
|
108 | ||
|
109 | # Fixed project and default tracker specified, but emails can override | |
|
110 | # both tracker and priority attributes: | |
|
111 | rdm-mailhandler --url https://domain.foo/redmine --key secret \\ | |
|
112 | --project foo \\ | |
|
113 | --tracker bug \\ | |
|
114 | --allow-override tracker,priority | |
|
115 | USAGE | |
|
116 | exit | |
|
117 | end | |
|
118 | ||
|
119 | 120 | def debug(msg) |
|
120 | 121 | puts msg if verbose |
|
121 | 122 | end |
General Comments 0
You need to be logged in to leave comments.
Login now