Добавлена команда импорта import из архива tar.gz

This commit is contained in:
Alexander Zhirov 2025-05-26 23:13:54 +03:00
parent cc85cdec78
commit 9c4c2c9d05
Signed by: alexander
GPG key ID: C8D8BE544A27C511
2 changed files with 127 additions and 0 deletions

View file

@ -18,6 +18,30 @@ int main(string[] args)
.add(new Command("init", "Initializing the repository for storing snapshots"))
.add(new Command("status", "Checking the status of tracked files"))
.add(new Command("diff", "Show changed data"))
.add(new Command("import", "Import snapshot from a tar.gz archive")
.add(new Argument("archive", "The path to the tar.gz archive file").required)
.add(new Option("c", "comment", "Specify comment")
.optional
.validateEachWith(
opt => opt.length > 0,
"cannot be empty"
)
)
.add(new Option("a", "author", "Specify author")
.optional
.validateEachWith(
opt => opt.length > 0,
"cannot be empty"
)
)
.add(new Option("e", "email", "Specify email")
.optional
.validateEachWith(
opt => opt.isValidEmail,
"must contain an email address"
)
)
)
.add(new Command("export", "Export snapshot to a tar.gz archive")
.add(new Argument("path", "Output directory path for the archive").required)
.add(new Option("s", "snapshot", "Specify snapshot hash")
@ -123,6 +147,14 @@ int main(string[] args)
e.arg("path"),
e.option("snapshot", ""),
)
)
.on("import", i =>
snag.importSnapshot(
i.arg("archive"),
i.option("comment", ""),
i.option("author", ""),
i.option("email", "")
)
);
} catch (SnagException e) {
e.print();