Serialize click commands to JSON (compatible with argdump schema)
Project description
clickdump
Serialize Click commands and groups.
Installation
pip install clickdump
Usage
import click
import clickdump
@click.command()
@click.option("-v", "--verbose", count=True, help="Verbosity")
@click.option("--name", default="world", help="Who to greet")
@click.argument("files", nargs=-1)
def cli(name, verbose, files):
"""A simple CLI tool."""
# Serialize to dict
data = clickdump.dump(cli)
# Serialize to JSON string
json_str = clickdump.dumps(cli, indent=2)
Groups and subcommands
@click.group()
@click.option("--debug/--no-debug", default=False)
def cli(debug):
"""A CLI with subcommands."""
@cli.command()
@click.option("--output", "-o", default="out.txt")
@click.argument("src")
def build(output, src):
"""Build the project."""
# Subcommand with parent for full program name
data = clickdump.dump(build, parent=cli)
# -> prog="cli build"
JSON Schema
Output follows the same schema as argdump
($schema: https://niwrap.dev/argdump/schema-v1.json).
Features
- All Click parameter types: options, arguments, flags, counts, choices, paths, files
- Nested groups with subparsers (click.Group)
- Type introspection: builtins, Path, Choice, File, IntRange, FloatRange, DateTime, UUID, Tuple, and callable converters
- Click-specific extensions:
hidden,envvar,prompt,show_default,is_flag,count,multiple,flag_value - Program name resolution via parent tree traversal for nested subcommands
- Mutual exclusion and argument group serialization
- Environment metadata (
$env) for reproducibility
Options
# Exclude environment metadata
clickdump.dump(cmd, include_env=False)
# Exclude hidden options
clickdump.dump(cmd, include_hidden=False)
# Compute full program name from parent group
clickdump.dump(subcmd, parent=root_group)
# Override the root program name
clickdump.dump(subcmd, parent=root_group, prog="mycli")
Limitations
- This is a serialize-only library (no
load/loadsequivalent). - Lambda and closure type converters cannot be fully serialized and will have
serializable: false. - Custom
click.ParamTypesubclasses that are not standard built-in types may be marked as unknown.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clickdump-0.1.0.tar.gz.
File metadata
- Download URL: clickdump-0.1.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b6d86dfc23ee2c682eedc05a752ee4c2bd51aed4bb8c046728ee7702967987e
|
|
| MD5 |
38ed780267307d58bf22e721032a8c3c
|
|
| BLAKE2b-256 |
4a0f7a81072a9591d029587864753a2334a24e6331cd985b3553168a1d86c68e
|
Provenance
The following attestation bundles were made for clickdump-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on styx-api/clickdump
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clickdump-0.1.0.tar.gz -
Subject digest:
1b6d86dfc23ee2c682eedc05a752ee4c2bd51aed4bb8c046728ee7702967987e - Sigstore transparency entry: 2107261372
- Sigstore integration time:
-
Permalink:
styx-api/clickdump@06deb68f26d312befa1e81f0c94d647b63ec4948 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/styx-api
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@06deb68f26d312befa1e81f0c94d647b63ec4948 -
Trigger Event:
push
-
Statement type:
File details
Details for the file clickdump-0.1.0-py3-none-any.whl.
File metadata
- Download URL: clickdump-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6eb1a28fa4ec6d8e4a609099e6383f6254f5acf9107f9a3362336e7225f0d477
|
|
| MD5 |
5314ba59e18d2cafe447af043624cf0f
|
|
| BLAKE2b-256 |
43138a3a7ea213cd2a1a50ef57878bb32a48088221b75852ccc0405153fe2cd8
|
Provenance
The following attestation bundles were made for clickdump-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on styx-api/clickdump
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clickdump-0.1.0-py3-none-any.whl -
Subject digest:
6eb1a28fa4ec6d8e4a609099e6383f6254f5acf9107f9a3362336e7225f0d477 - Sigstore transparency entry: 2107261439
- Sigstore integration time:
-
Permalink:
styx-api/clickdump@06deb68f26d312befa1e81f0c94d647b63ec4948 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/styx-api
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@06deb68f26d312befa1e81f0c94d647b63ec4948 -
Trigger Event:
push
-
Statement type: