From 9835924defca81a24d199cd8542ead28c167b43f Mon Sep 17 00:00:00 2001 From: Alexander Zhirov Date: Sun, 25 May 2025 13:21:52 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=9E=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=B2=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4?= =?UTF-8?q?=D0=B5=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=20=D1=81=D0=BD?= =?UTF-8?q?=D0=B8=D0=BC=D0=BA=D0=BE=D0=B2=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=B0=D1=80=D0=B8=D0=B9,=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F,=20?= =?UTF-8?q?=D1=8D=D0=BB=D0=B5=D0=BA=D1=82=D1=80=D0=BE=D0=BD=D0=BD=D1=83?= =?UTF-8?q?=D1=8E=20=D0=BF=D0=BE=D1=87=D1=82=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/snag/core/core.d | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/snag/core/core.d b/source/snag/core/core.d index 61f561c..5aae3ec 100644 --- a/source/snag/core/core.d +++ b/source/snag/core/core.d @@ -172,22 +172,31 @@ class Snag { writeln("Backup was created successfully: ", newSnapshot); } - void list() { + void list(bool comment, bool user, bool email) { 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:%ad\t%h" + "--pretty=" ~ format ], "Failed to retrieve the list of snapshots" ).output.split('\n').map!(line => line.split('\t')).array.each!(e => - writefln("%s\t%s\t%s", currentSnapshot == e[1] ? " >" : "", e[0], e[1]) + writefln("%s\t%s", + currentSnapshot == e[0] ? " >" : "", + e.join("\t") + ) ); } From eff4fa2fe6b01272f5c0def107724e87147769bf Mon Sep 17 00:00:00 2001 From: Alexander Zhirov Date: Sun, 25 May 2025 13:22:11 +0300 Subject: [PATCH 2/2] 0.0.7 --- source/app.d | 21 +++++++++++++++++++-- source/snag/version_.d | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/source/app.d b/source/app.d index d0ff61d..97c24ba 100644 --- a/source/app.d +++ b/source/app.d @@ -12,7 +12,20 @@ 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 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("restore", "Restore to the specified snapshot state") .add(new Argument("hash", "hash").required) ) @@ -50,7 +63,11 @@ int main(string[] args) snag.create() ) .on("list", list => - snag.list() + snag.list( + list.flag("comment"), + list.flag("user"), + list.flag("email") + ) ) .on("restore", restore => snag.restore(restore.arg("hash")) diff --git a/source/snag/version_.d b/source/snag/version_.d index b137cfa..2bdebb8 100644 --- a/source/snag/version_.d +++ b/source/snag/version_.d @@ -1,3 +1,3 @@ module snag.version_; -enum snagVersion = "0.0.6"; +enum snagVersion = "0.0.7";