Skip to content

Commit 220b230

Browse files
committed
feat(cli): add --extra-yaml to cci task info
1 parent f5a89df commit 220b230

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

cumulusci/cli/task.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from rich.console import Console
66
from rst2ansi import rst2ansi
77

8+
from cumulusci.cli.extra_yaml import resolve_extra_yaml
89
from cumulusci.core.config import TaskConfig
910
from cumulusci.core.exceptions import CumulusCIUsageError
1011
from cumulusci.utils import doc_task
@@ -95,8 +96,21 @@ def task_doc(runtime, project=False, write=False):
9596

9697
@task.command(name="info", help="Displays information for a task")
9798
@click.argument("task_name")
99+
@click.option(
100+
"--extra-yaml",
101+
"extra_yaml",
102+
multiple=True,
103+
type=click.Path(),
104+
help=(
105+
"Path to an additional YAML file to merge into the project config "
106+
"for this command only. Can be specified multiple times; later files "
107+
"override earlier ones. Also honors CUMULUSCI_EXTRA_YAML env var "
108+
"(colon-separated paths) as a fallback."
109+
),
110+
)
98111
@pass_runtime(require_project=False, require_keychain=True)
99-
def task_info(runtime, task_name):
112+
def task_info(runtime, task_name, extra_yaml):
113+
runtime.reload_project_config(additional_yaml=resolve_extra_yaml(extra_yaml))
100114
task_config = (
101115
runtime.project_config.get_task(task_name)
102116
if runtime.project_config is not None

cumulusci/cli/tests/test_task.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,36 @@ def test_task_doc_project_write(doc_task, echo, Path):
252252
def test_task_info(doc_task, rst2ansi):
253253
runtime = Mock()
254254
runtime.project_config.tasks__test = {"options": {}}
255-
run_click_command(task.task_info, runtime=runtime, task_name="test")
255+
run_click_command(task.task_info, runtime=runtime, task_name="test", extra_yaml=())
256256
doc_task.assert_called_once()
257257
rst2ansi.assert_called_once()
258258

259259

260+
@patch("cumulusci.cli.task.rst2ansi")
261+
@patch("cumulusci.cli.task.doc_task")
262+
def test_task_info__extra_yaml_applied(doc_task, rst2ansi, tmp_path):
263+
extra = tmp_path / "extra.yml"
264+
extra.write_text(
265+
"tasks:\n"
266+
" injected_task:\n"
267+
" description: injected\n"
268+
" class_path: cumulusci.tasks.util.Sleep\n"
269+
)
270+
runtime = Mock()
271+
runtime.project_config.tasks__injected_task = {"options": {}}
272+
273+
run_click_command(
274+
task.task_info,
275+
runtime=runtime,
276+
task_name="injected_task",
277+
extra_yaml=(str(extra),),
278+
)
279+
280+
runtime.reload_project_config.assert_called_once()
281+
call_kwargs = runtime.reload_project_config.call_args.kwargs
282+
assert "injected" in call_kwargs["additional_yaml"]
283+
284+
260285
class SetTrace(Exception):
261286
pass
262287

0 commit comments

Comments
 (0)