aboutsummaryrefslogtreecommitdiff
path: root/src/nix/add-to-store.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/add-to-store.cc')
-rw-r--r--src/nix/add-to-store.cc74
1 files changed, 44 insertions, 30 deletions
diff --git a/src/nix/add-to-store.cc b/src/nix/add-to-store.cc
index df51e72d5..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,36 +23,8 @@ 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 R"(
- Copy the file or directory *path* to the Nix store, and
- print the resulting store path on standard output.
- )";
- }
-
- Examples examples() override
- {
- return {
- };
}
- Category category() override { return catUtility; }
-
void run(ref<Store> store) override
{
if (!namePart) namePart = baseNameOf(path);
@@ -87,4 +60,45 @@ struct CmdAddToStore : MixDryRun, StoreCommand
}
};
-static auto rCmdAddToStore = registerCommand<CmdAddToStore>("add-to-store");
+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"});