跳转到主要内容

为cmd2添加命令缩写支持的插件

项目描述

cmd2-abbrev

描述

为cmd2提供之前已弃用的缩写行为的插件。

添加了一个名为 abbrev 的设置,允许用户控制是否可以使用命令缩写。如果应用程序有一个 speak 命令

(Cmd) speak hello
hello

则任何命令的唯一前缀都将运行该命令

(Cmd) set abbrev True
abbrev - was: False
now: True
(Cmd) sp hello
hello

非唯一缩写将生成语法错误

(Cmd) s hello
*** Unknown syntax: s hello
(Cmd) help

Documented commands (type help <topic>):
========================================
alias  help     load  pyscript  set    shortcuts  unalias
edit   history  py    quit      shell  speak

安装

系统要求:在cmd2工作的任何地方(Windows、Linux、MacOS)均可使用。需要 cmd2 版本0.9.12或更高版本。

使用pip安装

$ pip install cmd2-abbrev

通过混合 AbbrevMixin 类将此添加到您的 cmd2 应用程序中

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)

您必须在 cmd2.Cmd 之前混合 AbbrevMixin,否则它将无法正常工作。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

cmd2-abbrev-1.1.0.tar.gz (11.3 kB 查看哈希值)

上传时间 源代码

构建分发

cmd2_abbrev-1.1.0-py3-none-any.whl (4.0 kB 查看哈希值)

上传时间 Python 3

支持者