Commit 64c96491 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

[ctl] allow to specific instance name for instance commands in $CW_INSTANCE

Closes #17253994
parent 38d24fb2ae48
......@@ -21,6 +21,7 @@ provide a pluggable commands system.
# *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 @@ class InstanceCommand(Command):
arguments = '<instance>'
# enforce having one instance
min_args = max_args = 1
min_args = 0
max_args = 1
options = (
("force",
......@@ -142,7 +144,14 @@ class InstanceCommand(Command):
"""run the <command>_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
......
......@@ -49,6 +49,9 @@ New features
* 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
------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment