about summary refs log tree commit diff
path: root/nix-repl.cc
diff options
context:
space:
mode:
authorSusan Potter <me@susanpotter.net>2015-07-06T13·26-0500
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-06T13·53+0200
commit57aeef0b6a3d3c9506e35f57f5b6db33019967e5 (patch)
treee79b1c86200f84f5c9b921cc99950c9d669fca44 /nix-repl.cc
parent45c6405a30bd1b2cb8ad6a94b23be8b10cf52069 (diff)
Fix nix-repl does not support '--help'
According to popular practice and convention `nix-repl` now supports `--help`
like a good POSIX citizen[1].

[1] https://www.gnu.org/prep/standards/html_node/Command_002dLine-Interfaces.html
Diffstat (limited to 'nix-repl.cc')
-rw-r--r--nix-repl.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/nix-repl.cc b/nix-repl.cc
index 8cfbfeff9f4e..43e8c4a6cc68 100644
--- a/nix-repl.cc
+++ b/nix-repl.cc
@@ -59,7 +59,8 @@ struct NixRepl
 
 void printHelp()
 {
-    std::cout << "Usage: nix-repl\n";
+    std::cout << "Usage: nix-repl [--help|--version]";
+    std::cout << std::endl;
 }
 
 
@@ -601,6 +602,11 @@ int main(int argc, char * * argv)
         parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
             if (*arg == "--version")
                 printVersion("nix-repl");
+            else if (*arg == "--help") {
+                printHelp();
+                // exit with 0 since user asked for help
+                _exit(0);
+            }
             else if (parseSearchPathArg(arg, end, searchPath))
                 ;
             else if (*arg != "" && arg->at(0) == '-')