Compare commits

..

No commits in common. "eff4fa2fe6b01272f5c0def107724e87147769bf" and "11eecbf1282cd7c5ae73319a3b3506782b705fe0" have entirely different histories.

3 changed files with 6 additions and 32 deletions

View file

@ -12,20 +12,7 @@ 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("create", "Create a new backup"))
.add(new Command("list", "List of backups")
.add(new Flag("c", "comment", "Show comment")
.name("comment")
.optional
)
.add(new Flag("u", "user", "Show user")
.name("user")
.optional
)
.add(new Flag("e", "email", "Show email")
.name("email")
.optional
)
)
.add(new Command("list", "List of backups"))
.add(new Command("restore", "Restore to the specified snapshot state")
.add(new Argument("hash", "hash").required)
)
@ -63,11 +50,7 @@ int main(string[] args)
snag.create()
)
.on("list", list =>
snag.list(
list.flag("comment"),
list.flag("user"),
list.flag("email")
)
snag.list()
)
.on("restore", restore =>
snag.restore(restore.arg("hash"))

View file

@ -172,31 +172,22 @@ class Snag {
writeln("Backup was created successfully: ", newSnapshot);
}
void list(bool comment, bool user, bool email) {
void list() {
string currentSnapshot = git(
["rev-parse", "--short", "HEAD"],
"Failed to retrieve current snapshot information"
).output.strip('\n');
string format = "format:%h\t%ad";
comment && (format ~= "\t%s");
user && (format ~= "\t%an");
email && (format ~= "\t%ae");
git(
[
"log",
"--all",
"--date=format:%Y.%m.%d %H:%M",
"--pretty=" ~ format
"--pretty=format:%ad\t%h"
],
"Failed to retrieve the list of snapshots"
).output.split('\n').map!(line => line.split('\t')).array.each!(e =>
writefln("%s\t%s",
currentSnapshot == e[0] ? " >" : "",
e.join("\t")
)
writefln("%s\t%s\t%s", currentSnapshot == e[1] ? " >" : "", e[0], e[1])
);
}

View file

@ -1,3 +1,3 @@
module snag.version_;
enum snagVersion = "0.0.7";
enum snagVersion = "0.0.6";