aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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");