From 349c03321d5884fce7dbd1a9b425abbaf77cdded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Fri, 13 Nov 2015 13:04:27 +0100 Subject: [PATCH] [enh] Add auto-completion support in the cli --- debian/control | 3 ++- moulinette/interfaces/cli.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 626720a7..c6253815 100644 --- a/debian/control +++ b/debian/control @@ -14,7 +14,8 @@ Depends: ${misc:Depends}, ${python:Depends}, python-yaml, python-bottle (>= 0.12), python-gnupg, - python-gevent-websocket + python-gevent-websocket, + python-argcomplete Replaces: yunohost-cli Breaks: yunohost-cli Description: prototype interfaces with ease in Python diff --git a/moulinette/interfaces/cli.py b/moulinette/interfaces/cli.py index a4aeab4f..961b9543 100644 --- a/moulinette/interfaces/cli.py +++ b/moulinette/interfaces/cli.py @@ -7,6 +7,8 @@ import getpass import locale from argparse import SUPPRESS +import argcomplete + from moulinette.core import MoulinetteError from moulinette.interfaces import ( BaseActionsMapParser, BaseInterface, ExtendedArgumentParser, @@ -294,6 +296,9 @@ class Interface(BaseInterface): if output_as and output_as not in ['json', 'plain']: raise MoulinetteError(errno.EINVAL, m18n.g('invalid_usage')) + # auto-complete + argcomplete.autocomplete(self.actionsmap.parser._parser) + try: ret = self.actionsmap.process(args, timeout=5) except KeyboardInterrupt, EOFError: