Skip to content
Snippets Groups Projects
Commit 2ca28df6 authored by richardmaw-codethink's avatar richardmaw-codethink
Browse files

cli: Add artifact list subcommand

parent f169bcce
No related branches found
No related tags found
1 merge request!1008WIP: Add artifact checkout, list, list-contents, delete and diff subcommands
......@@ -150,6 +150,8 @@ def override_completions(cmd, cmd_param, args, incomplete):
complete_list = complete_target(args, incomplete)
complete_list.extend(complete_artifact(args, incomplete))
return complete_list
if cmd_param.name == 'artifact_prefix':
return complete_artifact(args, incomplete)
raise CompleteUnhandled()
......@@ -1188,6 +1190,28 @@ def artifact_delete(app, artifacts):
cache.cas.remove(ref, defer_prune=(i != len(artifacts)))
#################################################################
# Artifact List Command #
#################################################################
@artifact.command(name='list', short_help="List artifacts that match the prefix")
@click.option('--null', '-z', default=False, is_flag=True,
help="Separate tokens with NUL bytes instead of newlines")
@click.argument('artifact_prefix', type=click.Path(), nargs=-1)
@click.pass_obj
def artifact_list(app, null, artifact_prefix):
"""List artifact refs that match the prefix"""
sentinel = '\0' if null else '\n'
with app.initialized():
cas = app.context.artifactcache.cas
prefixes = _classify_artifact_refs(artifact_prefix, cas)
print(sentinel.join(ref for ref in cas.list_refs()
if any(ref.startswith(pfx) for pfx in prefixes)),
end=sentinel)
##################################################################
# DEPRECATED Commands #
##################################################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment