aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-07-24 20:42:24 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-12-03 18:09:02 +0100
commitef583303f0720d8bc9d6351cd769f92d5dd678f3 (patch)
tree8d15ff9adc90fb7d6a2499a33936e6ed0049f219 /src/nix
parent79c1967ded92574129c6a20116ef205a9c747bac (diff)
Move NAR-related commands to 'nix nar'
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/cat.cc6
-rw-r--r--src/nix/ls.cc8
-rw-r--r--src/nix/nar.cc31
3 files changed, 36 insertions, 9 deletions
diff --git a/src/nix/cat.cc b/src/nix/cat.cc
index eef172cfc..4fa1c9491 100644
--- a/src/nix/cat.cc
+++ b/src/nix/cat.cc
@@ -64,13 +64,11 @@ struct CmdCatNar : StoreCommand, MixCat
return "print the contents of a file inside a NAR file on stdout";
}
- Category category() override { return catUtility; }
-
void run(ref<Store> store) override
{
cat(makeNarAccessor(make_ref<std::string>(readFile(narPath))));
}
};
-static auto rCmdCatStore = registerCommand<CmdCatStore>("cat-store");
-static auto rCmdCatNar = registerCommand<CmdCatNar>("cat-nar");
+static auto rCmdCatStore = registerCommand2<CmdCatStore>({"store", "cat"});
+static auto rCmdCatNar = registerCommand2<CmdCatNar>({"nar", "cat"});
diff --git a/src/nix/ls.cc b/src/nix/ls.cc
index f39fdb2fd..d5fec4d84 100644
--- a/src/nix/ls.cc
+++ b/src/nix/ls.cc
@@ -134,7 +134,7 @@ struct CmdLsNar : Command, MixLs
return {
Example{
"To list a specific file in a NAR:",
- "nix ls-nar -l hello.nar /bin/hello"
+ "nix nar ls -l hello.nar /bin/hello"
},
};
}
@@ -144,13 +144,11 @@ struct CmdLsNar : Command, MixLs
return "show information about a path inside a NAR file";
}
- Category category() override { return catUtility; }
-
void run() override
{
list(makeNarAccessor(make_ref<std::string>(readFile(narPath))));
}
};
-static auto rCmdLsStore = registerCommand<CmdLsStore>("ls-store");
-static auto rCmdLsNar = registerCommand<CmdLsNar>("ls-nar");
+static auto rCmdLsStore = registerCommand2<CmdLsStore>({"store", "ls"});
+static auto rCmdLsNar = registerCommand2<CmdLsNar>({"nar", "ls"});
diff --git a/src/nix/nar.cc b/src/nix/nar.cc
new file mode 100644
index 000000000..e239ce96a
--- /dev/null
+++ b/src/nix/nar.cc
@@ -0,0 +1,31 @@
+#include "command.hh"
+
+using namespace nix;
+
+struct CmdNar : NixMultiCommand
+{
+ CmdNar() : MultiCommand(RegisterCommand::getCommandsFor({"nar"}))
+ { }
+
+ std::string description() override
+ {
+ return "query the contents of NAR files";
+ }
+
+ Category category() override { return catUtility; }
+
+ void run() override
+ {
+ if (!command)
+ throw UsageError("'nix nar' requires a sub-command.");
+ command->second->prepare();
+ command->second->run();
+ }
+
+ void printHelp(const string & programName, std::ostream & out) override
+ {
+ MultiCommand::printHelp(programName, out);
+ }
+};
+
+static auto rCmdNar = registerCommand<CmdNar>("nar");