diff options
Diffstat (limited to 'src/nix/dump-path.cc')
-rw-r--r-- | src/nix/dump-path.cc | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/src/nix/dump-path.cc b/src/nix/dump-path.cc index 6fd197531..c4edc894b 100644 --- a/src/nix/dump-path.cc +++ b/src/nix/dump-path.cc @@ -1,5 +1,6 @@ #include "command.hh" #include "store-api.hh" +#include "archive.hh" using namespace nix; @@ -7,21 +8,16 @@ struct CmdDumpPath : StorePathCommand { std::string description() override { - return "dump a store path to stdout (in NAR format)"; + return "serialise a store path to stdout in NAR format"; } - Examples examples() override + std::string doc() override { - return { - Example{ - "To get a NAR from the binary cache https://cache.nixos.org/:", - "nix dump-path --store https://cache.nixos.org/ /nix/store/7crrmih8c52r8fbnqb933dxrsp44md93-glibc-2.25" - }, - }; + return + #include "store-dump-path.md" + ; } - Category category() override { return catUtility; } - void run(ref<Store> store, const StorePath & storePath) override { FdSink sink(STDOUT_FILENO); @@ -30,4 +26,39 @@ struct CmdDumpPath : StorePathCommand } }; -static auto rDumpPath = registerCommand<CmdDumpPath>("dump-path"); +static auto rDumpPath = registerCommand2<CmdDumpPath>({"store", "dump-path"}); + +struct CmdDumpPath2 : Command +{ + Path path; + + CmdDumpPath2() + { + expectArgs({ + .label = "path", + .handler = {&path}, + .completer = completePath + }); + } + + std::string description() override + { + return "serialise a path to stdout in NAR format"; + } + + std::string doc() override + { + return + #include "nar-dump-path.md" + ; + } + + void run() override + { + FdSink sink(STDOUT_FILENO); + dumpPath(path, sink); + sink.flush(); + } +}; + +static auto rDumpPath2 = registerCommand2<CmdDumpPath2>({"nar", "dump-path"}); |