[sheepdog] [PATCH v2 2/2] man: print detailed usage for sheep if available

MORITA Kazutaka morita.kazutaka at gmail.com
Thu Aug 15 04:45:00 CEST 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 script/gen_man.pl |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/script/gen_man.pl b/script/gen_man.pl
index 67d3b5e..7f25df4 100755
--- a/script/gen_man.pl
+++ b/script/gen_man.pl
@@ -17,6 +17,17 @@ sub sheep {
 	my ($opt, $longopt, $desc) = ($1, $2, $3);
 	print escape(header("$opt, $longopt") . "\n");
 	print escape("$desc\n");
+
+	next if ($opt eq '-h');
+
+	# extract detailed help if available
+	my $tmpfile = `mktemp`;
+	chomp($tmpfile);
+	my $help = `$program $tmpfile $opt 2> /dev/null`;
+	unlink $tmpfile;
+
+	$help =~ s/^\s+\$.+/\n$&\n/mg;
+	print escape("\n$help");
     }
 }
 
-- 
1.7.9.5




More information about the sheepdog mailing list