Skip to main content

Wrapper around Click python library

Project description

A wrapper around the Click library for Python. PyCmds makes it easier to use Click’s command execution framework independently of the command line (i.e. executing Click Commands in an existing Python instance.)

To accompany this, PyCmds adds a CmdCompleter class which implements the Completer interface from the python-prompt-toolkit. Using this class, one may create a python-prompt-toolkit interface with intelligent (see below) autocompletion for Click Commands and Options.

Also, PyCmds adds an AliasGroup class to allow the assignment of aliases to Click Commands.

CmdCompleter Features

  • Only displays completion menu when the completer is certain of what options or subcommands are valid. (E.g. no naive option or subcommand suggestions when Click is expecting a value for a previous option.)
  • Considers click.Option.is_flag and click.Parameter.nargs to decide how many values a option should consume.
  • Considers click.Option.count and click.Option.multiple to decide if more than one instance of the same option should be permitted.
  • Smart autocompletion for grouped short flags with or without a value clustered on the end.

Important Notes About CmdCompleter

  • Designed primarily for POSIX-style options.
  • Only context settings specified on the root/top-level Command will be considered (by necessity).
  • Incompatible with click.Context.allow_interspersed_args.
  • Incompatible with click.Context.ignore_unknown_opts.
  • Incompatible with click.MultiCommand.chain.
  • The split character for parameters with nargs > 1 is expected to be a space.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pycmds, version 1.0.4
Filename, size File type Python version Upload date Hashes
Filename, size pycmds-1.0.4-py3-none-any.whl (12.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pycmds-1.0.4.tar.gz (11.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page