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/mauveconsole | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'bin/mauveconsole') diff --git a/bin/mauveconsole b/bin/mauveconsole index 5a16a7e..c9a4656 100755 --- a/bin/mauveconsole +++ b/bin/mauveconsole @@ -1,26 +1,26 @@ #!/usr/bin/ruby1.8 # NAME -# # mauveconsole -- Ruby console to query the mauvealert server directly # # SYNOPSIS -# -# mauveconsole [-h | --help] [] +# mauveconsole [-h | --help] [-V | --version] [-m | --manual] [] # # OPTIONS -# -# -h, --help Show a help message -# File to load the configuration from. If none is +# -h, --help Show a help message, and exit +# +# -m, --manual Show this manual, and exit +# +# -V, --version Show the version number, 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 -# # irb(1), mauveserver(1), mauveclient(1) # # AUTHOR -# # Patrick J Cherry # @@ -30,21 +30,39 @@ def error(msg) exit 1 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? configuration_file = File.expand_path(configuration_file) -- cgit v1.2.1