about summary refs log tree commit diff
path: root/src/libmain/shared.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-03T20·37-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-03T20·40-0400
commita562d544d8520a0f113ad1a348e28ea00f27b693 (patch)
tree5e8d7200b8521aa54e2c8846ef7c31fd5dac737e /src/libmain/shared.cc
parent9c41c66c5b877dbb529f6147b28384a57a591895 (diff)
When ‘--help’ is given, just run ‘man’ to show the manual page
I.e. do what git does.  I'm too lazy to keep the builtin help text up
to date :-)

Also add ‘--help’ to various commands that lacked it
(e.g. nix-collect-garbage).
Diffstat (limited to 'src/libmain/shared.cc')
-rw-r--r--src/libmain/shared.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 5f92c3df34a0..f8149fc608fd 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -91,6 +91,7 @@ string getArg(const string & opt,
     return *i;
 }
 
+
 /* Initialize and reorder arguments, then call the actual argument
    processor. */
 static void initAndRun(int argc, char * * argv)
@@ -275,6 +276,14 @@ static void * oomHandler(size_t requested)
 }
 
 
+void showManPage(const string & name)
+{
+    string cmd = "man " + name;
+    if (system(cmd.c_str()) != 0)
+        throw Error(format("command `%1%' failed") % cmd);
+}
+
+
 int exitCode = 0;
 char * * argvSaved = 0;