Skip to content

Commit a678f79

Browse files
committed
Print [done] for alias/grouping tasks and update README example
Alias tasks (no cmd, only depends-on) now print a [done] completion line after their dependencies finish, making it clear the requested task was fulfilled. The README quick-start output is updated to match the real CLI format and includes a brief explanation for new users.
1 parent 75b87b4 commit a678f79

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ tasks:
2828
depends-on: [test, lint]
2929
```
3030
31-
```
31+
Running `check` resolves its dependencies and runs them in order:
32+
33+
```console
3234
$ conda task run check
33-
▶ build
34-
▶ lint
35-
▶ test
35+
[run] build: python -m build
36+
[run] lint: ruff check .
37+
[run] test: pytest tests/ -v
38+
[done] check
3639
```
3740

3841
## Why?

conda_tasks/cli/run.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,7 @@ def execute_run(args: argparse.Namespace) -> int:
178178
cwd,
179179
)
180180

181+
if not quiet and tasks[target_name].is_alias:
182+
print(f" [done] {target_name}")
183+
181184
return 0

tests/cli/test_run.py

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ def test_execute_run_dry_run_with_deps(tmp_path, capsys):
9999
assert "build" in output
100100

101101

102-
def test_execute_run_dry_run_alias_skipped(tmp_path, capsys):
103-
"""Alias tasks (no cmd) are silently skipped during dry-run."""
102+
def test_execute_run_dry_run_alias_done(tmp_path, capsys):
103+
"""Alias tasks print [done] after their dependencies in dry-run."""
104104
task_file = tmp_path / "conda-tasks.yml"
105105
task_file.write_text(
106106
"tasks:\n"
@@ -114,7 +114,45 @@ def test_execute_run_dry_run_alias_skipped(tmp_path, capsys):
114114
output = capsys.readouterr().out
115115
assert "[dry-run] lint" in output
116116
assert "[dry-run] test" in output
117-
assert "[dry-run] check" not in output
117+
assert "[done] check" in output
118+
119+
120+
def test_execute_run_alias_done(tmp_path, capsys, monkeypatch):
121+
"""Alias tasks print [done] after dependencies finish executing."""
122+
task_file = tmp_path / "conda-tasks.yml"
123+
task_file.write_text(
124+
"tasks:\n"
125+
" lint:\n cmd: 'ruff check .'\n"
126+
" test:\n cmd: 'pytest'\n"
127+
" check:\n depends-on: [lint, test]\n"
128+
)
129+
130+
fake = FakeShell()
131+
monkeypatch.setattr(run_mod, "SubprocessShell", lambda: fake)
132+
result = execute_run(_run_args(task_file, task_name="check"))
133+
134+
assert result == 0
135+
output = capsys.readouterr().out
136+
assert "[run] lint" in output
137+
assert "[run] test" in output
138+
assert "[done] check" in output
139+
140+
141+
def test_execute_run_alias_quiet(tmp_path, capsys, monkeypatch):
142+
"""Quiet mode suppresses [done] for alias tasks."""
143+
task_file = tmp_path / "conda-tasks.yml"
144+
task_file.write_text(
145+
"tasks:\n"
146+
" lint:\n cmd: 'ruff check .'\n"
147+
" check:\n depends-on: [lint]\n"
148+
)
149+
150+
fake = FakeShell()
151+
monkeypatch.setattr(run_mod, "SubprocessShell", lambda: fake)
152+
result = execute_run(_run_args(task_file, task_name="check", quiet=True))
153+
154+
assert result == 0
155+
assert capsys.readouterr().out == ""
118156

119157

120158
def test_execute_run_list_command(tmp_path, capsys):

0 commit comments

Comments
 (0)