fastcommand
Python module for defining multi-command cli programs
Description
The fastcommand module is a lightweight wrapper over argparse which aims to make it easier to write multi-command cli programs and utilities. It does so by providing convenience decorators that allow for quickly defining sub-commands.
Usage
Example
import fastcommand
@fastcommand.command("hello", help="say hello")
def command_hello(options):
print("Hello, World!")
@fastcommand.command("goodbye", help="say goodbye", arguments=[
fastcommand.Argument("name"),
fastcommand.Argument("--wave", "-w", action="store_true", default=False)
])
def command_goodbye(options):
print(f"Goodbye, {options.name}!")
if options.wave:
print("👋")
def main():
cli = fastcommand.CommandParser(description="Simple fastcommand example.")
cli.use_logging(format="[%(levelname)s] %(message)s")
cli.run()
if __name__ == "__main__":
main()
Autocomplete
fastcommand provides autocomplete using argcomplete. Enable it by adding the following the argcomplete marker to the to of your application:
# PYTHON_ARGCOMPLETE_OK
Install argcomplete locally to be able to use autocomplete:
pip install argcomplete
And then either:
-
activate globally by running:
activate-global-python-argcomplete
-
activate it for a specific command by running:
eval "$(register-python-argcomplete my-python-app)"
See the argcomplete documentation for more details.
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 fastcommand-0.2.1.tar.gz.
File metadata
- Download URL: fastcommand-0.2.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6060b5b0a3914cf8ab9a2e2f60ca82610d9a29254cc608ddd11093308c05ac8
|
|
| MD5 |
8640535e70834af14c601a8c06f10bf7
|
|
| BLAKE2b-256 |
199bc63eeb636d5793a34f5090af30a8d47db9322b724d915f5aeaac932a72a2
|
Provenance
The following attestation bundles were made for fastcommand-0.2.1.tar.gz:
Publisher:
build.yaml on jbmorley/fastcommand
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastcommand-0.2.1.tar.gz -
Subject digest:
a6060b5b0a3914cf8ab9a2e2f60ca82610d9a29254cc608ddd11093308c05ac8 - Sigstore transparency entry: 2356961802
- Sigstore integration time:
-
Permalink:
jbmorley/fastcommand@c0103d7cfd85fe9f4f4504117a313469e469c289 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jbmorley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yaml@c0103d7cfd85fe9f4f4504117a313469e469c289 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastcommand-0.2.1-py3-none-any.whl.
File metadata
- Download URL: fastcommand-0.2.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3083c989d6121b351a09fe50e5942477165b8cc4883ac9f8506099c3a96a3f9b
|
|
| MD5 |
64c3bfc6d8358571ce619164e141471c
|
|
| BLAKE2b-256 |
bec07f2b7559e04e22d88eb6566ca42691016f4f240dd9f36b80a5f30a294993
|
Provenance
The following attestation bundles were made for fastcommand-0.2.1-py3-none-any.whl:
Publisher:
build.yaml on jbmorley/fastcommand
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastcommand-0.2.1-py3-none-any.whl -
Subject digest:
3083c989d6121b351a09fe50e5942477165b8cc4883ac9f8506099c3a96a3f9b - Sigstore transparency entry: 2356962437
- Sigstore integration time:
-
Permalink:
jbmorley/fastcommand@c0103d7cfd85fe9f4f4504117a313469e469c289 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jbmorley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yaml@c0103d7cfd85fe9f4f4504117a313469e469c289 -
Trigger Event:
push
-
Statement type: