aboutsummaryrefslogtreecommitdiff
path: root/bin/mauveserver
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-07-15 15:27:55 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-07-15 15:27:55 +0100
commiteb76e0b20da5ac71f304a930df5c0f9fcf56652b (patch)
treeeaaa973f051740ec3fb8025508f121d06452dfd3 /bin/mauveserver
parent18b0906630ab4165d1e8b4bc66d7446b17c31605 (diff)
* Upped the version to 3.1.0.
* Added a Mauve::VERSION constant * Updated manpages, and help to be better.
Diffstat (limited to 'bin/mauveserver')
-rwxr-xr-xbin/mauveserver43
1 files changed, 32 insertions, 11 deletions
diff --git a/bin/mauveserver b/bin/mauveserver
index 4ac5a6d..9d1cf53 100755
--- a/bin/mauveserver
+++ b/bin/mauveserver
@@ -1,24 +1,26 @@
#! /usr/bin/ruby1.8
# NAME
-#
# mauveserver -- receive alerts from station(s) around the network
#
# SYNOPSIS
-#
-# mauveserver [ -h | --help ] [<configuration file>]
+# mauveserver [ -h | --help ] [-m | --manual] [-V | --version] [<configuration file>]
#
# OPTIONS
+# -h, --help Show a help message, and exit.
#
-# -h, --help Show a help message
+# -V, --version Show the version, and exit.
#
-# <configuration file> File to load the configuration from
+# -m, --manual Show this manual, and exit.
+#
+# <configuration file> File from whence to load the configuration. If none is
+# specified, then mauvealert.conf in the current
+# directory is used, and failing that
+# /etc/mauvealert/mauvealert.conf is used.
#
# SEE ALSO
-#
# mauveclient(1), mauveconsole(1)
#
# AUTHOR
-#
# Patrick J Cherry <patrick@bytemark.co.uk>
#
@@ -34,21 +36,40 @@ rescue SyntaxError => no_blocks_with_procs
error "mauveserver must have Ruby 1.8.7 or later"
end
+help = ARGV.any?{|a| a =~ /-(h|-help)/}
+version = ARGV.any?{|a| a =~ /-(V|-version)/}
+manual = ARGV.any?{|a| a =~ /-(m|-manual)/}
+
+#
# CAUTION! Kwality kode.
#
-if ARGV.any?{|a| a =~ /--?h(elp)?/}
+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
+require 'mauve/version'
+
+puts "#{$0}: version "+Mauve::VERSION if version
+
+exit 0 if help or version or manual
configuration_file = ARGV.shift
configuration_file = [".", "/etc/mauvealert/"].collect{|x| File.join("mauveserver.conf") }.find{|d| File.file?(d)} if configuration_file.nil?