https://github.com/ro5bert/pycmds
Wrapper around Click python library
https://github.com/ro5bert/pycmds
command prompt-toolkit python-click python3
Last synced: 10 months ago
JSON representation
Wrapper around Click python library
- Host: GitHub
- URL: https://github.com/ro5bert/pycmds
- Owner: Ro5bert
- License: mit
- Created: 2018-09-01T19:01:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-13T14:58:14.000Z (over 7 years ago)
- Last Synced: 2025-02-25T23:35:34.393Z (10 months ago)
- Topics: command, prompt-toolkit, python-click, python3
- Language: Python
- Homepage:
- Size: 38.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
PyCmds
======
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
``Command``\s 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 ``Command``\s and ``Option``\s.
Also, PyCmds adds an ``AliasGroup`` class to allow the assignment of aliases
to Click ``Command``\s.
``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.