From ebcb0d42c59f8b1e2f5e68a738391d999bda0dd0 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 24 Oct 2024 17:54:34 +0200 Subject: [PATCH] feat(ls): default to show selected paths, --all flag to show all #37 --- backupbot.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backupbot.py b/backupbot.py index c0b3374..9a78d19 100755 --- a/backupbot.py +++ b/backupbot.py @@ -415,14 +415,19 @@ def snapshots(): @cli.command() @click.option('snapshot', '--snapshot', '-s', envvar='SNAPSHOT', default='latest') -@click.option('path', '--path', '-p', envvar='INCLUDE_PATH') -def ls(snapshot, path): +@click.option('show_all', '--all', '-a', envvar='SHOW_ALL', is_flag=True) +@click.argument('path', required=False, default='/') +def ls(snapshot, show_all, path): if snapshot == 'latest': latest_snapshot = get_snapshots('latest') if not latest_snapshot: logger.error(f"There is no latest snapshot for {SERVICE}") exit(1) snapshot = latest_snapshot[0]['short_id'] + if path != '/' and os.environ.get('INCLUDE_PATH'): + path = os.environ.get('INCLUDE_PATH') + if show_all: + path = None results = list_files(snapshot, path) for r in results: if r.get('path'):