aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/mauveclient42
-rwxr-xr-xbin/mauveconsole42
-rwxr-xr-xbin/mauveserver43
3 files changed, 97 insertions, 30 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)
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] [<configuration file>]
+# mauveconsole [-h | --help] [-V | --version] [-m | --manual] [<configuration file>]
#
# OPTIONS
-#
-# -h, --help Show a help message
-# <configuration file> 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
+#
+# <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
-#
# irb(1), mauveserver(1), mauveclient(1)
#
# AUTHOR
-#
# Patrick J Cherry <patrick@bytemark.co.uk>
#
@@ -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)
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?