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.0.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.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file fastcommand-0.2.0.tar.gz.

File metadata

  • Download URL: fastcommand-0.2.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for fastcommand-0.2.0.tar.gz
Algorithm Hash digest
SHA256 91e7ceef0df21d2f6d9840c3ed22b2543ea978b0de5a8b9e716da560a0aab4fe
MD5 5659d40a8b8beb2275e5b3c5337724eb
BLAKE2b-256 ac2d01004d0f940cdf2a59527980ba4631ed61499c5e1d92c97a35a78ec2f6d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastcommand-0.2.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: fastcommand-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for fastcommand-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e3d8734bceaec0d33229a4c681a1cf2a5e27fb62e43443fe8b55a5875545be80
MD5 88b1f99d984bcb06a21b81afc2bd94dc
BLAKE2b-256 f525f3134b629450fd797598f53260d806f2f074f27a976e1b8350a7cd4d4dfb

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastcommand-0.2.0-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

0.2.1

2 files

This release

0.2.0 This release

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