Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sub-command alternative to the readme #937

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions docs/_includes/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -3361,9 +3361,20 @@ makefiles and they will still have the environment variables setup from the pare
For tasks that can be skipped in case no input file has been modified, see the [Running Tasks Only If Sources Changed](#usage-running-tasks-only-if-sources-changed) section.

<a name="usage-command-groups"></a>
### Command Groups
### Command Groups (Subcommands)

You can expose the tasks as *groups* by creating a top level task which will call other internal tasks.

There are two possible approaches for this.

#### Local tasks

Using private tasks (private is not mandatory) are more suited for simple cases and redirect one command to another.

This approach has some limitations:
- `--list-all-steps` will not list private tasks
- the tasks required a specific naming pattern

You can expose the tasks as *groups* by creating a top level task which will call other internal private tasks (private is not mandatory).<br>
For example, if you want to have server start/stop and client start/stop commands and execute them as follows:

```sh
Expand Down Expand Up @@ -3416,6 +3427,35 @@ command = "echo"
args = ["stopping client..."]
```

#### Extenal subcommand file

Another approach is to use a different configuration file for the subcommands.

This allows using `--list-all-steps` for the subcommand and also set `[config]` options in the subcommand file.

For projects with subprojects in folders, a `Makefile.toml` can be created for each subproject and be reached as subcommands from the main folder.

Example implementation of a `foo` sobcommand with a configuration file in the `foo/` folder.

```toml
[tasks.foo]
description = "Foo subcommands"
category = "Subcommands"
cwd = "foo/"
command = "makers"
args = ["${@}"]
```

Example implementation of a `foo` sobcommand with a `Makefile.foo.toml` configuration file in the same folder.

```toml
[tasks.foo]
description = "Foo subcommands"
category = "Subcommands"
command = "makers"
args = ["--makefile", "Makefile.foo.toml", "${@}"]
```

<a name="usage-diff-changes"></a>
### Diff Changes
Using the **`--diff-steps`** CLI command flag, you can diff your correct overrides compared to the prebuilt internal makefile flow.
Expand Down
2 changes: 1 addition & 1 deletion docs/_includes/nav.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
* [Modifying Predefined Tasks/Flows](#usage-predefined-flows-modify)
* [Minimal Version](#usage-min-version)
* [Performance Tuning](#usage-performance-tuning)
* [Command Groups](#usage-command-groups)
* [Command Groups (Subcommands)](#usage-command-groups)
* [Diff Changes](#usage-diff-changes)
* [Unstable Features](#usage-unstable-features)
* [CLI Options](#usage-cli)
Expand Down
Loading