diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-02-17 17:11:14 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-02-17 17:11:21 +0100 |
commit | f33878b6562c746d5865a86e64f02c75feaf5b3e (patch) | |
tree | 4323175e89733abb3c093bd86d761647fdba8a14 /src/nix/main.cc | |
parent | cced73496b835b545be91cbebc4f89f61a7b106f (diff) |
Make 'nix --version -vv' work
Fixes #3743.
Diffstat (limited to 'src/nix/main.cc')
-rw-r--r-- | src/nix/main.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/nix/main.cc b/src/nix/main.cc index ef5e41a55..5f4eb8918 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -61,6 +61,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs bool printBuildLogs = false; bool useNet = true; bool refresh = false; + bool showVersion = false; NixArgs() : MultiCommand(RegisterCommand::getCommandsFor({})), MixCommonArgs("nix") { @@ -87,7 +88,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs addFlag({ .longName = "version", .description = "Show version information.", - .handler = {[&]() { if (!completions) printVersion(programName); }}, + .handler = {[&]() { showVersion = true; }}, }); addFlag({ @@ -280,6 +281,11 @@ void mainWrapped(int argc, char * * argv) initPlugins(); + if (args.showVersion) { + printVersion(programName); + return; + } + if (!args.command) throw UsageError("no subcommand specified"); |