Show CID for asset uploads

- Display IPFS CID after upload
- Show recipe syntax with :cid

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-12 07:36:44 +00:00
parent 09edf9f59e
commit c0414a9e0d

View File

@@ -519,7 +519,7 @@ def import_file(filepath):
@cli.command()
@click.argument("filepath", type=click.Path(exists=True))
def upload(filepath):
"""Upload a file to cache (works with remote servers). Requires login."""
"""Upload a file to cache and IPFS. Requires login."""
# Check auth
token_data = load_token()
if not token_data.get("access_token"):
@@ -536,8 +536,11 @@ def upload(filepath):
sys.exit(1)
resp.raise_for_status()
result = resp.json()
click.echo(f"Uploaded: {result['content_hash']}")
click.echo(f"CID: {result['cid']}")
click.echo(f"Size: {result['size']} bytes")
click.echo()
click.echo("Use in recipes:")
click.echo(f' (asset my-asset :cid "{result["cid"]}")')
except requests.RequestException as e:
click.echo(f"Upload failed: {e}", err=True)
sys.exit(1)