From 57aeef0b6a3d3c9506e35f57f5b6db33019967e5 Mon Sep 17 00:00:00 2001 From: Susan Potter Date: Mon, 6 Jul 2015 08:26:17 -0500 Subject: [PATCH] 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 --- nix-repl.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nix-repl.cc b/nix-repl.cc index 8cfbfeff9..43e8c4a6c 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) == '-')