summaryrefslogtreecommitdiffstats
path: root/bin/puppetdoc
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-08-29 17:12:57 +0000
committerLuke Kanies <luke@madstop.com>2005-08-29 17:12:57 +0000
commitcdfaa5ea36926caae58f30db86ed898cde82b874 (patch)
tree3071f78fa20c14a466e420653ed5178c083ed84e /bin/puppetdoc
parentf2795359521709b5d4a64900ebed5e7b0be84c6b (diff)
downloadpuppet-cdfaa5ea36926caae58f30db86ed898cde82b874.tar.gz
puppet-cdfaa5ea36926caae58f30db86ed898cde82b874.tar.xz
puppet-cdfaa5ea36926caae58f30db86ed898cde82b874.zip
adding RDoc::usage documentation to all executables
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@595 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'bin/puppetdoc')
-rwxr-xr-xbin/puppetdoc85
1 files changed, 61 insertions, 24 deletions
diff --git a/bin/puppetdoc b/bin/puppetdoc
index e64ca0624..4a7693be7 100755
--- a/bin/puppetdoc
+++ b/bin/puppetdoc
@@ -1,45 +1,81 @@
-#!/usr/local/bin/ruby
-#!/usr/bin/ruby -w
+#!/usr/bin/ruby
-#--------------------
-# produce documentation on all of the puppet types
#
-# $Id$
-
-
-$:.unshift '../lib'
+# = Synopsis
+#
+# Generate a reference for all Puppet types. Largely meant for internal Reductive
+# Labs use.
+#
+# = Usage
+#
+# puppetdoc [-h|--help]
+#
+# = Description
+#
+# This command generates a restructured-text document describing all installed
+# Puppet types. It is largely meant for internal use and is used to generate
+# the reference document available on the Reductive Labs web site.
+#
+# = Options
+#
+# help::
+# Print this help message
+#
+# = Example
+#
+# $ puppetdoc > /tmp/reference.rst
+#
+# = Author
+#
+# Luke Kanies
+#
+# = Copyright
+#
+# Copyright (c) 2005 Reductive Labs, LLC
+# Licensed under the GNU Public License
require 'puppet'
require 'getoptlong'
+$haveusage = true
+
+begin
+ require 'rdoc/usage'
+rescue
+ $haveusage = false
+end
+
def tab(num)
return $tab * num
end
result = GetoptLong.new(
- [ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
[ "--help", "-h", GetoptLong::NO_ARGUMENT ]
)
debug = false
-logfile = false
$tab = " "
-result.each { |opt,arg|
- case opt
- when "--help"
- puts "There is no help yet"
- exit
- when "--debug"
- debug = true
- when "--logfile"
- logfile = arg
- else
- raise "Invalid option '#{opt}'"
- end
-}
+begin
+ result.each { |opt,arg|
+ case opt
+ when "--help"
+ if $haveusage
+ RDoc::usage && exit
+ else
+ puts "No help available unless you have RDoc::usage installed"
+ exit
+ end
+ end
+ }
+rescue GetoptLong::InvalidOption => detail
+ $stderr.puts "Try '#{$0} --help'"
+ #if $haveusage
+ # RDoc::usage_no_exit('usage')
+ #end
+ exit(1)
+end
puts %{
==============
@@ -127,3 +163,4 @@ puts "
"
puts "\n*This page autogenerated on %s*" % Time.now
+# $Id$