Skip to content

Commit 8064df3

Browse files
committed
Update docs based on json output.
1 parent afe52f5 commit 8064df3

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

docs/built_in_tasks.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ task init --driver mydriver
3636

3737
List available tasks.
3838

39+
Use `--json` or `-j` to output a JSON array of task names (e.g. `["task1","task2",...]`) for machine parsing. With no tasks, output is `[]`.
40+
3941
``` bash
4042

4143
# List all tasks available
@@ -47,6 +49,10 @@ task list --global
4749
# List all local tasks
4850
task list --local
4951

52+
# List all tasks as JSON (machine-readable)
53+
task list -a --json
54+
task list -a -j
55+
5056
```
5157

5258
## Edit
@@ -102,11 +108,17 @@ task goto proj
102108

103109
Show Help.
104110

111+
Use `--json` or `-j` to output a single JSON object with `description`, `required`, `optional` (arrays of `{ "long", "short", "type" }`), and `subcommands` (array of objects with `name`, `description`, `required`, `optional`) for machine parsing. Both `task help mycommand --json` and `task help --json mycommand` work.
112+
105113
``` bash
106114

107115
# Show help for mycommand
108116
task help mycommand
109117

118+
# Show help as JSON (machine-readable)
119+
task help mycommand --json
120+
task help mycommand -j
121+
110122
```
111123

112124
## Template

docs/task_files.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ These are set up to be loaded in the .bashrc during installation.
6262

6363
Any other additions to the user environment have to be initiated by the user.
6464

65+
## Global flags
66+
67+
Global flags are given before the task name and control runner output:
68+
69+
| Flag | Long form | Effect |
70+
|------|-----------|--------|
71+
| `+v` | `+verbose` | Enable verbose runner diagnostics (logged to stderr). Example: `task +v run_test` |
72+
| `+s` | `+silent` | Suppress runner and driver chatter (stderr); only the task’s stdout is shown. Use for machine-parseable output. Example: `task +s list -a` |
73+
74+
If both are given, the last one wins. Example: `task +v +s run_test` runs in silent mode.
75+
6576
## Task Variables
6677

6778
Each task function is spawned inside of a subshell by the task function.
@@ -101,7 +112,8 @@ For the sake of completeness, the following variables are also accessable, but s
101112
| DRIVER_VALIDATE_TASK_FILE | Driver function to validate task file | bash_validate_file |
102113
| LOCAL_TASKS_REG | A regex list of local tasks | `build|run|kill` |
103114
| GLOBAL_TASKS_REG | A regex list of global tasks | `list|help|global|driver|module` |
104-
| GLOBAL_VERBOSE | Set to true to log _tmverbose_echo calls to stdout | 1 |
115+
| GLOBAL_VERBOSE | Set by the `+v` or `+verbose` global flag; when set, _tmverbose_echo logs runner diagnostics to stderr | 1 |
116+
| GLOBAL_SILENT | Set by the `+s` or `+silent` global flag; when set, runner and driver chatter (stderr) is discarded so only task stdout is produced (for machine-parseable output) | 1 |
105117
| GLOBAL_TASK_FILE | The file to load global tasks | $TASK_MASTER_HOME/lib/global-tasks.sh |
106118

107119
### Task Variable Conventions

0 commit comments

Comments
 (0)