diff --git a/docs/source_files/pixi_tomls/task_visibility.toml b/docs/source_files/pixi_tomls/task_visibility.toml new file mode 100644 index 0000000000..ca62dfb16b --- /dev/null +++ b/docs/source_files/pixi_tomls/task_visibility.toml @@ -0,0 +1,23 @@ +[workspace] +channels = [] +platforms = [] + +# --8<-- [start:project_tasks] +# Hidden task that is only intended to be used by other tasks +[tasks._git-clone] +args = ["url"] +cmd = "echo git clone {{ url }}" + +# Hidden task that clones a dependency +[tasks._clone-subproject] +depends-on = [ + { task = "_git-clone", args = [ + "https://git.hub/org/subproject.git", + ] }, +] + +# Task to build the project which depends on cloning a dependency +[tasks.build] +cmd = "echo Building project" +depends-on = ["_clone-subproject"] +# --8<-- [end:project_tasks] diff --git a/docs/workspace/advanced_tasks.md b/docs/workspace/advanced_tasks.md index 8be10c4459..65fd09f1d2 100644 --- a/docs/workspace/advanced_tasks.md +++ b/docs/workspace/advanced_tasks.md @@ -80,6 +80,8 @@ pixi task add lint pylint --8<-- "docs/source_files/pixi_tomls/pixi_task_alias.toml:not-all" ``` +!!! tip "Hiding Tasks" + Tasks can be hidden from user facing commands by [naming them](#task-names) with an `_` prefix. ### Shorthand Syntax @@ -268,6 +270,20 @@ You can also use filters to transform argument values: For more information about available filters and template syntax, see the [MiniJinja documentation](https://docs.rs/minijinja/latest/minijinja/filters/index.html). +## Task Names + +A task name follows these rules: + +- **No spaces** are allowed in the name. +- Must **be unique** within the table. +- [`_`]("underscores") at the start of the name will **hide** the task from the `pixi task list` command. + +Hiding tasks can be useful if your project defines many tasks but your users only need to use a subset of them. + +```toml title="pixi.toml" +--8<-- "docs/source_files/pixi_tomls/task_visibility.toml:project_tasks" +``` + ## Caching When you specify `inputs` and/or `outputs` to a task, Pixi will reuse the result of the task.