1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 14:21:48 +02:00

Move NAR-related commands to 'nix nar'

This commit is contained in:
Eelco Dolstra 2020-07-24 20:42:24 +02:00
parent 79c1967ded
commit ef583303f0
6 changed files with 54 additions and 27 deletions

View file

@ -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"});

View file

@ -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"});

31
src/nix/nar.cc Normal file
View file

@ -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");