# HG changeset patch # User Laurent Peuch # Date 1573041170 -3600 # Node ID 22ece66dcd4721898ebc17abf8d6b8007a7c3caf # Parent 38d24fb2ae4882603a13355b95ca203cb6b4e9d1 [ctl] allow to specific instance name for instance commands in $CW_INSTANCE Closes #17253994 diff -r 38d24fb2ae48 -r 22ece66dcd47 cubicweb/cwctl.py --- a/cubicweb/cwctl.py Tue Nov 05 23:19:15 2019 +0100 +++ b/cubicweb/cwctl.py Wed Nov 06 12:52:50 2019 +0100 @@ -21,6 +21,7 @@ # *ctl module should limit the number of import to be imported as quickly as # possible (for cubicweb-ctl reactivity, necessary for instance for usable bash # completion). So import locally in command helpers. +import os import sys import traceback from warnings import filterwarnings @@ -107,7 +108,8 @@ arguments = '' # enforce having one instance - min_args = max_args = 1 + min_args = 0 + max_args = 1 options = ( ("force", @@ -142,7 +144,14 @@ """run the _method on each argument (a list of instance identifiers) """ - appid = args[0] + if not args: + if "CW_INSTANCE" in os.environ: + appid = os.environ["CW_INSTANCE"] + else: + raise BadCommandUsage("Error: instance id is missing") + else: + appid = args[0] + cmdmeth = getattr(self, '%s_instance' % self.name) traceback_ = None diff -r 38d24fb2ae48 -r 22ece66dcd47 doc/changes/3.27.rst --- a/doc/changes/3.27.rst Tue Nov 05 23:19:15 2019 +0100 +++ b/doc/changes/3.27.rst Wed Nov 06 12:52:50 2019 +0100 @@ -49,6 +49,9 @@ * add a new '-t/--toolbar' option the pyramid command to activate the pyramid debugtoolbar +* allow to specify the instance id for any instance command using the + CW_INSTANCE global variable instead of or giving it as a cli argument + Backwards incompatible changes ------------------------------