Skip to content

Commit 8e05f38

Browse files
authored
Merge pull request #199 from kaloyan13/master
add list-files command
2 parents fc2403b + 9edd20d commit 8e05f38

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Commands:
7171
download Download last version of Mergin Maps project
7272
download-file Download project file at specified version.
7373
list-projects List projects on the server
74+
list-files List files in a project
7475
login Login to the service and see how to set the token...
7576
pull Fetch changes from Mergin Maps repository
7677
push Upload local changes into Mergin Maps repository

mergin/cli.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,27 @@ def reset(ctx):
661661
except Exception as e:
662662
_print_unhandled_exception()
663663

664+
@cli.command()
665+
@click.argument("project")
666+
@click.option("--json", is_flag=True, default=False, help="Output in JSON format")
667+
@click.pass_context
668+
def list_files(ctx, project, json):
669+
"""List files in a project."""
670+
671+
mc = ctx.obj["client"]
672+
if mc is None:
673+
return
674+
675+
project_info = mc.project_info(project)
676+
project_files = project_info["files"]
677+
678+
if json:
679+
print(project_files)
680+
else:
681+
click.echo("Fetched {} files .".format(len(project_files)))
682+
for file in project_files:
683+
click.echo(" {:40}\t{:6.1f} MB".format(file['path'], file["size"] / (1024 * 1024)))
684+
664685

665686
if __name__ == "__main__":
666687
cli()

0 commit comments

Comments
 (0)