https://github.com/python-cmd2/cmd2-abbrev
Plugin for cmd2 to support old abbreviation behavior
https://github.com/python-cmd2/cmd2-abbrev
Last synced: 11 months ago
JSON representation
Plugin for cmd2 to support old abbreviation behavior
- Host: GitHub
- URL: https://github.com/python-cmd2/cmd2-abbrev
- Owner: python-cmd2
- License: mit
- Created: 2018-05-25T23:27:03.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-06-11T07:07:34.000Z (almost 5 years ago)
- Last Synced: 2025-05-08T21:48:49.202Z (11 months ago)
- Language: Python
- Size: 26.4 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# cmd2-abbrev
## Description
Plugin for cmd2 to support previously deprecated abbreviation behavior.
Adds a setting `abbrev` which allows users to control whether commands
can be abbreviated. If an application has a `speak` command:
```
(Cmd) speak hello
hello
```
then any unique prefix of any command will run the command:
```
(Cmd) set abbrev True
abbrev - was: False
now: True
(Cmd) sp hello
hello
```
Non-unique abbreviations generate a syntax error:
```
(Cmd) s hello
*** Unknown syntax: s hello
(Cmd) help
Documented commands (type help ):
========================================
alias help load pyscript set shortcuts unalias
edit history py quit shell speak
```
## Installation
System requirements: works anywhere `cmd2` works (Windows, Linux, MacOS).
Requires `cmd2` version 0.9.12 or higher.
Install using pip:
```
$ pip install cmd2-abbrev
```
Add to your `cmd2` application by mixing in the `AbbrevMixin` class:
```python
import cmd2
import cmd2_abbrev
class AbbrevExample(cmd2_abbrev.AbbrevMixin, cmd2.Cmd):
"""A cmd2 program to demonstrate the use of the cmd2_abbrev plugin"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
```
You must mix in `AbbrevMixin` before `cmd2.Cmd` or it won't work properly.