mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[enh] Add auto-completion support in the cli
This commit is contained in:
parent
2e83d9d1ff
commit
349c03321d
2 changed files with 7 additions and 1 deletions
3
debian/control
vendored
3
debian/control
vendored
|
@ -14,7 +14,8 @@ Depends: ${misc:Depends}, ${python:Depends},
|
||||||
python-yaml,
|
python-yaml,
|
||||||
python-bottle (>= 0.12),
|
python-bottle (>= 0.12),
|
||||||
python-gnupg,
|
python-gnupg,
|
||||||
python-gevent-websocket
|
python-gevent-websocket,
|
||||||
|
python-argcomplete
|
||||||
Replaces: yunohost-cli
|
Replaces: yunohost-cli
|
||||||
Breaks: yunohost-cli
|
Breaks: yunohost-cli
|
||||||
Description: prototype interfaces with ease in Python
|
Description: prototype interfaces with ease in Python
|
||||||
|
|
|
@ -7,6 +7,8 @@ import getpass
|
||||||
import locale
|
import locale
|
||||||
from argparse import SUPPRESS
|
from argparse import SUPPRESS
|
||||||
|
|
||||||
|
import argcomplete
|
||||||
|
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
from moulinette.interfaces import (
|
from moulinette.interfaces import (
|
||||||
BaseActionsMapParser, BaseInterface, ExtendedArgumentParser,
|
BaseActionsMapParser, BaseInterface, ExtendedArgumentParser,
|
||||||
|
@ -294,6 +296,9 @@ class Interface(BaseInterface):
|
||||||
if output_as and output_as not in ['json', 'plain']:
|
if output_as and output_as not in ['json', 'plain']:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.g('invalid_usage'))
|
raise MoulinetteError(errno.EINVAL, m18n.g('invalid_usage'))
|
||||||
|
|
||||||
|
# auto-complete
|
||||||
|
argcomplete.autocomplete(self.actionsmap.parser._parser)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ret = self.actionsmap.process(args, timeout=5)
|
ret = self.actionsmap.process(args, timeout=5)
|
||||||
except KeyboardInterrupt, EOFError:
|
except KeyboardInterrupt, EOFError:
|
||||||
|
|
Loading…
Add table
Reference in a new issue