diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-15 15:27:55 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-15 15:27:55 +0100 |
commit | eb76e0b20da5ac71f304a930df5c0f9fcf56652b (patch) | |
tree | eaaa973f051740ec3fb8025508f121d06452dfd3 /bin/mauveclient | |
parent | 18b0906630ab4165d1e8b4bc66d7446b17c31605 (diff) |
* Upped the version to 3.1.0.
* Added a Mauve::VERSION constant
* Updated manpages, and help to be better.
Diffstat (limited to 'bin/mauveclient')
-rwxr-xr-x | bin/mauveclient | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/bin/mauveclient b/bin/mauveclient index e3bc453..12747fa 100755 --- a/bin/mauveclient +++ b/bin/mauveclient @@ -4,6 +4,7 @@ # # SYNOPSIS # mauveclient [<destination>] +# [ --help | -h ] [ --manual | -m ] [ --version | -V ] # [--source | -o <source>] [--replace | -p] [--verbose | -v] # [--id <alertid> ... ] # @@ -40,6 +41,12 @@ # specify it twice, it will print the entire data # structure. # +# --help, -h Display a short help message, and exit. +# +# --manual, -m Display this manual, and exit. +# +# --version, -V Display the version number for Mauve and exit. +# # You can specify any number of alerts in an update - every time you specify # --id starts a new alert. # @@ -67,7 +74,6 @@ # no time is specified, "now" is assumed. See # SPECIFYING TIMES below for the format of <time>. # -# # SPECIFYING TIMES # # Times can be specified for an alert to be raised or cleared. This can be @@ -155,7 +161,7 @@ require 'getoptlong' require 'mauve/sender' require 'mauve/proto' require 'mauve/mauve_time' -require 'pp' +require 'mauve/version' NOW = Mauve::MauveTime.now @@ -205,9 +211,13 @@ begin message = nil verbose = 0 help = false + manual = false + version = false opts = GetoptLong.new( ['-h', '--help', GetoptLong::NO_ARGUMENT], + ['-m', '--manual', GetoptLong::NO_ARGUMENT], + ['-V', '--version', GetoptLong::NO_ARGUMENT], ['-o', '--source', GetoptLong::OPTIONAL_ARGUMENT], ['-p', '--replace', GetoptLong::NO_ARGUMENT], ['-i', '--id', GetoptLong::OPTIONAL_ARGUMENT], @@ -222,11 +232,15 @@ begin # # Can catch empty arguments better if we set the GetoptLong things to # "optional" rather than "required" and catch the empty arg here. - error "#{opt} cannot be empty" if arg.empty? and not %w(-h -p -v -c -r).include?(opt) + error "#{opt} cannot be empty" if arg.empty? and not %w(-h -m -V -p -v -c -r).include?(opt) case opt when '-h' help = true + when '-m' + manual = true + when '-V' + version = true when '-p' update.replace = true when '-i' @@ -255,19 +269,33 @@ begin # CAUTION! Kwality kode. # - if help + if manual or help # Open the file, stripping the shebang line lines = File.open(__FILE__){|fh| fh.readlines}[1..-1] + found_synopsis = false + lines.each do |line| - line.chomp! + + line.chomp! break if line.empty? + + if help and !found_synopsis + found_synopsis = (line =~ /^#\s+SYNOPSIS\s*$/) if !found_synopsis + next + end + puts line[2..-1].to_s - end - exit 0 + break if help and found_synopsis and line =~ /^#\s*$/ + + end end + puts "#{$0}: version "+Mauve::VERSION if version + + exit 0 if help or version or manual + error "No alerts specified" unless !update.alert.empty? || update.replace update.transmission_id = rand(2**63) |