11

继承 Python 的 cmd.Cmd 类实现的命令行程序,能实现自动补全功能吗?

 3 years ago
source link: https://www.v2ex.com/t/779434
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Python

继承 Python 的 cmd.Cmd 类实现的命令行程序,能实现自动补全功能吗?

  XIVN1987 · 1 天前 · 339 次点击

文档中有如下内容:

class cmd.Cmd(completekey='tab', stdin=None, stdout=None) 

Cmd.completedefault(text, line, begidx, endidx) 
Method called to complete an input line when no command-specific complete_*() method is available. By default, it returns an empty list.

按照理解,输入命令的时候按 Tab 键应该能自动补全,,可是我试了下就在本行添加了空格,,并没有补全行为,,也没有调用覆写的 completedefault 方法,,哪位知道是什么原因?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK