Skip to content

Commit 78eb47d

Browse files
committed
add list-files command
1 parent b153764 commit 78eb47d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

mergin/cli.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,29 @@ def reset(ctx):
653653
except Exception as e:
654654
_print_unhandled_exception()
655655

656+
@cli.command()
657+
@click.argument("namespace")
658+
@click.argument("project")
659+
@click.option("--fmt_json", is_flag=True, default=False, help="Output in JSON format")
660+
@click.pass_context
661+
def list_files(ctx, namespace, project,fmt_json):
662+
"""List files in a project."""
663+
664+
mc = ctx.obj["client"]
665+
if mc is None:
666+
return
667+
668+
#projects_files = mc.projects_files(name=project, namespace=namespace)
669+
project_info = mc.project_info(namespace + "/" + project)
670+
project_files = project_info["files"]
671+
672+
if fmt_json:
673+
print(project_files)
674+
else:
675+
click.echo("Fetched {} files .".format(len(project_files)))
676+
for file in project_files:
677+
click.echo(" {:40}\t{:6.1f} MB".format(file['path'], file["size"] / (1024 * 1024)))
678+
656679

657680
if __name__ == "__main__":
658681
cli()

0 commit comments

Comments
 (0)