From 141bedb069ba83775715a6159dbe090d8a856c82 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 24 Oct 2024 18:09:33 +0200 Subject: [PATCH] feat(ls): add --timestamps flag #37 --- backupbot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backupbot.py b/backupbot.py index 78d951b..96b9a7f 100755 --- a/backupbot.py +++ b/backupbot.py @@ -416,8 +416,9 @@ def snapshots(): @cli.command() @click.option('snapshot', '--snapshot', '-s', envvar='SNAPSHOT', default='latest') @click.option('show_all', '--all', '-a', envvar='SHOW_ALL', is_flag=True) +@click.option('timestamps', '--timestamps', '-t', envvar='TIMESTAMPS', is_flag=True) @click.argument('path', required=False, default='/var/lib/docker/volumes/') -def ls(snapshot, show_all, path): +def ls(snapshot, show_all, timestamps, path): if snapshot == 'latest': latest_snapshot = get_snapshots('latest') if not latest_snapshot: @@ -431,7 +432,10 @@ def ls(snapshot, show_all, path): results = list_files(snapshot, path) for r in results: if r.get('path'): - print(f"{r['ctime']}\t{r['path']}") + if timestamps: + print(f"{r['ctime']}\t{r['path']}") + else: + print(f"{r['path']}") def list_files(snapshot, path):