From a562d544d8520a0f113ad1a348e28ea00f27b693 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 3 Oct 2012 16:37:06 -0400 Subject: =?UTF-8?q?When=20=E2=80=98--help=E2=80=99=20is=20given,=20just=20?= =?UTF-8?q?run=20=E2=80=98man=E2=80=99=20to=20show=20the=20manual=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- src/libmain/shared.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/libmain/shared.cc') diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 5f92c3df3..f8149fc60 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; -- cgit v1.2.3