Use RDoc.usage
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1867 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
a07a6d4aa4
commit
9afaf26d66
|
@ -1,13 +1,51 @@
|
||||||
#!/usr/bin/ruby
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
# rdm-mailhandler
|
# == Synopsis
|
||||||
|
#
|
||||||
# Reads an email from standard input and forward it to a Redmine server
|
# Reads an email from standard input and forward it to a Redmine server
|
||||||
# Can be used from a remote mail server
|
# through a HTTP request.
|
||||||
|
#
|
||||||
|
# == Usage
|
||||||
|
#
|
||||||
|
# rdm-mailhandler [options] --url=<Redmine URL> --key=<API key>
|
||||||
|
#
|
||||||
|
# == Arguments
|
||||||
|
#
|
||||||
|
# -u, --url URL of the Redmine server
|
||||||
|
# -k, --key Redmine API key
|
||||||
|
#
|
||||||
|
# General options:
|
||||||
|
# -h, --help show this help
|
||||||
|
# -v, --verbose show extra information
|
||||||
|
# -V, --version show version information and exit
|
||||||
|
#
|
||||||
|
# Issue attributes control options:
|
||||||
|
# -p, --project=PROJECT identifier of the target project
|
||||||
|
# -t, --tracker=TRACKER name of the target tracker
|
||||||
|
# --category=CATEGORY name of the target category
|
||||||
|
# --priority=PRIORITY name of the target priority
|
||||||
|
# -o, --allow-override=ATTRS allow email content to override attributes
|
||||||
|
# specified by previous options
|
||||||
|
# ATTRS is a comma separated list of attributes
|
||||||
|
#
|
||||||
|
# == Examples
|
||||||
|
# No project specified. Emails MUST contain the 'Project' keyword:
|
||||||
|
#
|
||||||
|
# rdm-mailhandler --url http://redmine.domain.foo --key secret
|
||||||
|
#
|
||||||
|
# Fixed project and default tracker specified, but emails can override
|
||||||
|
# both tracker and priority attributes using keywords:
|
||||||
|
#
|
||||||
|
# rdm-mailhandler --url https://domain.foo/redmine --key secret \\
|
||||||
|
# --project foo \\
|
||||||
|
# --tracker bug \\
|
||||||
|
# --allow-override tracker,priority
|
||||||
|
|
||||||
require 'net/http'
|
require 'net/http'
|
||||||
require 'net/https'
|
require 'net/https'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'getoptlong'
|
require 'getoptlong'
|
||||||
|
require 'rdoc/usage'
|
||||||
|
|
||||||
module Net
|
module Net
|
||||||
class HTTPS < HTTP
|
class HTTPS < HTTP
|
||||||
|
@ -31,15 +69,15 @@ class RedmineMailHandler
|
||||||
self.issue_attributes = {}
|
self.issue_attributes = {}
|
||||||
|
|
||||||
opts = GetoptLong.new(
|
opts = GetoptLong.new(
|
||||||
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
||||||
[ '--version', '-V', GetoptLong::NO_ARGUMENT ],
|
[ '--version', '-V', GetoptLong::NO_ARGUMENT ],
|
||||||
[ '--verbose', '-v', GetoptLong::NO_ARGUMENT ],
|
[ '--verbose', '-v', GetoptLong::NO_ARGUMENT ],
|
||||||
[ '--url', '-u', GetoptLong::REQUIRED_ARGUMENT ],
|
[ '--url', '-u', GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
[ '--key', '-k', GetoptLong::REQUIRED_ARGUMENT],
|
[ '--key', '-k', GetoptLong::REQUIRED_ARGUMENT],
|
||||||
[ '--project', '-p', GetoptLong::REQUIRED_ARGUMENT ],
|
[ '--project', '-p', GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
[ '--tracker', '-t', GetoptLong::REQUIRED_ARGUMENT],
|
[ '--tracker', '-t', GetoptLong::REQUIRED_ARGUMENT],
|
||||||
[ '--category', GetoptLong::REQUIRED_ARGUMENT],
|
[ '--category', GetoptLong::REQUIRED_ARGUMENT],
|
||||||
[ '--priority', GetoptLong::REQUIRED_ARGUMENT],
|
[ '--priority', GetoptLong::REQUIRED_ARGUMENT],
|
||||||
[ '--allow-override', '-o', GetoptLong::REQUIRED_ARGUMENT]
|
[ '--allow-override', '-o', GetoptLong::REQUIRED_ARGUMENT]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -62,7 +100,7 @@ class RedmineMailHandler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
usage if url.nil?
|
RDoc.usage if url.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def submit(email)
|
def submit(email)
|
||||||
|
@ -79,43 +117,6 @@ class RedmineMailHandler
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def usage
|
|
||||||
puts <<-USAGE
|
|
||||||
Usage: rdm-mailhandler [options] --url=<Redmine URL> --key=<API key>
|
|
||||||
Reads an email from standard input and forward it to a Redmine server
|
|
||||||
|
|
||||||
Required:
|
|
||||||
-u, --url URL of the Redmine server
|
|
||||||
-k, --key Redmine API key
|
|
||||||
|
|
||||||
General options:
|
|
||||||
-h, --help show this help
|
|
||||||
-v, --verbose show extra information
|
|
||||||
-V, --version show version information and exit
|
|
||||||
|
|
||||||
Issue attributes control options:
|
|
||||||
-p, --project=PROJECT identifier of the target project
|
|
||||||
-t, --tracker=TRACKER name of the target tracker
|
|
||||||
--category=CATEGORY name of the target category
|
|
||||||
--priority=PRIORITY name of the target priority
|
|
||||||
-o, --allow-override=ATTRS allow email content to override attributes
|
|
||||||
specified by previous options
|
|
||||||
ATTRS is a comma separated list of attributes
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
# No project specified. Emails MUST contain the 'Project' keyword:
|
|
||||||
rdm-mailhandler --url http://redmine.domain.foo --key secret
|
|
||||||
|
|
||||||
# Fixed project and default tracker specified, but emails can override
|
|
||||||
# both tracker and priority attributes:
|
|
||||||
rdm-mailhandler --url https://domain.foo/redmine --key secret \\
|
|
||||||
--project foo \\
|
|
||||||
--tracker bug \\
|
|
||||||
--allow-override tracker,priority
|
|
||||||
USAGE
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
|
|
||||||
def debug(msg)
|
def debug(msg)
|
||||||
puts msg if verbose
|
puts msg if verbose
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue