Skip to main content

fastcommand

build

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

fastcommand-0.2.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastcommand-0.2.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

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

Hashes for fastcommand-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a6060b5b0a3914cf8ab9a2e2f60ca82610d9a29254cc608ddd11093308c05ac8
MD5 8640535e70834af14c601a8c06f10bf7
BLAKE2b-256 199bc63eeb636d5793a34f5090af30a8d47db9322b724d915f5aeaac932a72a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastcommand-0.2.1.tar.gz:

Publisher: build.yaml on jbmorley/fastcommand

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for fastcommand-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3083c989d6121b351a09fe50e5942477165b8cc4883ac9f8506099c3a96a3f9b
MD5 64c3bfc6d8358571ce619164e141471c
BLAKE2b-256 bec07f2b7559e04e22d88eb6566ca42691016f4f240dd9f36b80a5f30a294993

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastcommand-0.2.1-py3-none-any.whl:

Publisher: build.yaml on jbmorley/fastcommand

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page