diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-12-04 00:58:09 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-12-04 00:59:24 +0100 |
commit | f337aa70998141ccfaa956e9f670152dbb15b385 (patch) | |
tree | 7563c50f1cc90ea34ca45bd66d8962d4c9fff6bc /src/nix/add-to-store.cc | |
parent | 8df58eae4c6f074b8e33a5bcb0c73b6700e34d5a (diff) |
Split 'nix store add-to-store' into 'add-path' and 'add-file'
This makes it consistent with 'nix hash <path|file>'.
Diffstat (limited to 'src/nix/add-to-store.cc')
-rw-r--r-- | src/nix/add-to-store.cc | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/src/nix/add-to-store.cc b/src/nix/add-to-store.cc index 66822b0ff..ea4bbbab9 100644 --- a/src/nix/add-to-store.cc +++ b/src/nix/add-to-store.cc @@ -9,10 +9,11 @@ struct CmdAddToStore : MixDryRun, StoreCommand { Path path; std::optional<std::string> namePart; - FileIngestionMethod ingestionMethod = FileIngestionMethod::Recursive; + FileIngestionMethod ingestionMethod; CmdAddToStore() { + // FIXME: completion expectArg("path", &path); addFlag({ @@ -22,25 +23,6 @@ struct CmdAddToStore : MixDryRun, StoreCommand .labels = {"name"}, .handler = {&namePart}, }); - - addFlag({ - .longName = "flat", - .shortName = 0, - .description = "add flat file to the Nix store", - .handler = {&ingestionMethod, FileIngestionMethod::Flat}, - }); - } - - std::string description() override - { - return "add a path to the Nix store"; - } - - std::string doc() override - { - return - #include "add-to-store.md" - ; } void run(ref<Store> store) override @@ -78,4 +60,45 @@ struct CmdAddToStore : MixDryRun, StoreCommand } }; -static auto rCmdAddToStore = registerCommand2<CmdAddToStore>({"store", "add-path"}); +struct CmdAddFile : CmdAddToStore +{ + CmdAddFile() + { + ingestionMethod = FileIngestionMethod::Flat; + } + + std::string description() override + { + return "add a regular file to the Nix store"; + } + + std::string doc() override + { + return + #include "add-file.md" + ; + } +}; + +struct CmdAddPath : CmdAddToStore +{ + CmdAddPath() + { + ingestionMethod = FileIngestionMethod::Recursive; + } + + std::string description() override + { + return "add a path to the Nix store"; + } + + std::string doc() override + { + return + #include "add-path.md" + ; + } +}; + +static auto rCmdAddFile = registerCommand2<CmdAddFile>({"store", "add-file"}); +static auto rCmdAddPath = registerCommand2<CmdAddPath>({"store", "add-path"}); |