From eb76e0b20da5ac71f304a930df5c0f9fcf56652b Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 15 Jul 2011 15:27:55 +0100 Subject: * Upped the version to 3.1.0. * Added a Mauve::VERSION constant * Updated manpages, and help to be better. --- bin/mauveserver | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'bin/mauveserver') 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 ] [] +# mauveserver [ -h | --help ] [-m | --manual] [-V | --version] [] # # OPTIONS +# -h, --help Show a help message, and exit. # -# -h, --help Show a help message +# -V, --version Show the version, and exit. # -# File to load the configuration from +# -m, --manual Show this manual, and exit. +# +# 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 # @@ -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? -- cgit v1.2.1