Configuration¶
taskfile-help can be configured via multiple methods with a clear priority order.
Configuration Methods¶
taskfile-help supports configuration through:
- Command-line arguments - Highest priority
- Environment variables - Shell or
.envfile - Configuration files -
taskfile_help.yml(preferred) orpyproject.toml(fallback) - Default values - Built-in defaults
Configuration Files¶
taskfile-help supports two configuration file formats:
taskfile_help.yml (Recommended)¶
A dedicated YAML configuration file for taskfile-help settings. This file takes precedence over pyproject.toml if both exist.
Example:
# taskfile_help.yml
search-dirs:
- "."
- "taskfiles"
- "../shared"
no-color: false
group-pattern: "\\s*#\\s*===\\s*(.+?)\\s*==="
pyproject.toml (Alternative)¶
Configuration can also be specified in pyproject.toml under the [tool.taskfile-help] section. This is useful for Python projects that already use pyproject.toml.
Example:
[tool.taskfile-help]
search-dirs = [".", "taskfiles", "../shared"]
no-color = false
group-pattern = "\\s*#\\s*===\\s*(.+?)\\s*==="
File Precedence: If both taskfile_help.yml and pyproject.toml exist in the current directory, taskfile_help.yml takes precedence.
Supported Configuration Options¶
The following table shows all available configuration options and their supported configuration methods:
| Option | CLI Flag | Environment Variable(s) | Config File | .env File | Default |
|---|---|---|---|---|---|
| search-dirs | --search-dirs, -s |
TASKFILE_HELP_SEARCH_DIRS |
search-dirs |
✓ | Current directory |
| no-color | --no-color |
NO_COLOR, TASKFILE_HELP_NO_COLOR |
no-color |
✓ | Auto-detect TTY |
| group-pattern | --group-pattern |
TASKFILE_HELP_GROUP_PATTERN |
group-pattern |
✓ | \s*#\s*===\s*(.+?)\s*=== |
| verbose | --verbose, -v |
- | - | - | false |
| json | --json |
- | - | - | false |
Priority Order: Command-line > Environment Variables > Config File (taskfile_help.yml or pyproject.toml) > Defaults
Note: Environment variables can be set in your shell or in a .env file in the current directory.
Quick Examples¶
# Using command-line arguments
taskfile-help --no-color --search-dirs /path/to/project
# Using environment variables
export TASKFILE_HELP_SEARCH_DIRS=.:../shared
export NO_COLOR=1
taskfile-help
# Using .env file
cat > .env << EOF
TASKFILE_HELP_SEARCH_DIRS=.:../shared
TASKFILE_HELP_GROUP_PATTERN=\s*##\s*(.+?)\s*##
NO_COLOR=1
EOF
taskfile-help
# Using taskfile_help.yml (recommended)
cat > taskfile_help.yml << EOF
search-dirs:
- "."
- "../shared"
no-color: false
group-pattern: "\\\\s*##\\\\s*(.+?)\\\\s*##"
EOF
taskfile-help
# Using pyproject.toml (alternative)
cat >> pyproject.toml << EOF
[tool.taskfile-help]
search-dirs = [".", "../shared"]
group-pattern = "\\\\s*##\\\\s*(.+?)\\\\s*##"
no-color = true
EOF
taskfile-help
Command-Line Options¶
Namespace Selection¶
# Show main Taskfile ([Tt]askfile\.ya?ml)
taskfile-help
taskfile-help main
# Show specific namespace ([Tt]askfile[-_](?P<namespace>\w+)\.ya?ml)
taskfile-help dev
taskfile-help test
taskfile-help rag
Show All Taskfiles¶
Displays tasks from all Taskfiles (main + all namespaces).
Color Control¶
# Disable colors
taskfile-help --no-color
# Colors are automatically disabled when:
# - Output is piped (e.g., taskfile-help | cat)
# - Output is redirected (e.g., taskfile-help > file.txt)
# - Using --json output
Search Directories¶
# Search in specific directory
taskfile-help --search-dirs /path/to/project
taskfile-help -s /path/to/project
# Search multiple directories (first match wins)
taskfile-help --search-dirs /path1:/path2:/path3
taskfile-help -s ~/projects/main:~/projects/shared
# Relative paths (resolved from current directory)
taskfile-help --search-dirs ../other-project
taskfile-help -s ./subdir:../shared
JSON Output¶
Output format:
{
"tasks": [
{
"group": "Build",
"name": "build",
"full_name": "build",
"description": "Build the project"
},
{
"group": "Build",
"name": "compile",
"full_name": "compile",
"description": "Compile sources"
}
]
}
For namespaces:
{
"tasks": [
{
"group": "Development",
"name": "serve",
"full_name": "dev:serve",
"description": "Start development server"
}
]
}
Verbose Output¶
Shows search directories being used:
Group Pattern¶
# Use custom group pattern
taskfile-help --group-pattern '\s*##\s*(.+?)\s*##'
# Use alternative pattern
taskfile-help --group-pattern '\s*#\s*---\s*(.+?)\s*---'
Customize the regular expression pattern used to identify group markers in Taskfiles. The pattern must contain one capture group that extracts the group name.
Configuration File Options¶
You can configure default settings in either taskfile_help.yml or pyproject.toml:
taskfile_help.yml:
pyproject.toml:
Configuration Options¶
search-dirs¶
List of directories to search for Taskfiles.
taskfile_help.yml:
# Single directory
search-dirs:
- "."
# Multiple directories
search-dirs:
- "."
- "../shared"
- "~/common"
# Absolute and relative paths
search-dirs:
- "."
- "../other-project"
- "/opt/shared-tasks"
- "~/my-tasks"
pyproject.toml:
[tool.taskfile-help]
# Single directory
search-dirs = ["."]
# Multiple directories
search-dirs = [".", "../shared", "~/common"]
# Absolute and relative paths
search-dirs = [
".",
"../other-project",
"/opt/shared-tasks",
"~/my-tasks"
]
no-color¶
Disable colored output by default.
taskfile_help.yml:
pyproject.toml:
group-pattern¶
Regular expression pattern for identifying group markers in Taskfiles.
taskfile_help.yml:
# Default pattern (matches: # === Group Name ===)
group-pattern: "\\s*#\\s*===\\s*(.+?)\\s*==="
# Custom pattern (matches: ## Group Name ##)
group-pattern: "\\s*##\\s*(.+?)\\s*##"
# Alternative pattern (matches: # --- Group Name ---)
group-pattern: "\\s*#\\s*---\\s*(.+?)\\s*---"
pyproject.toml:
[tool.taskfile-help]
# Default pattern (matches: # === Group Name ===)
group-pattern = "\\s*#\\s*===\\s*(.+?)\\s*==="
# Custom pattern (matches: ## Group Name ##)
group-pattern = "\\s*##\\s*(.+?)\\s*##"
# Alternative pattern (matches: # --- Group Name ---)
group-pattern = "\\s*#\\s*---\\s*(.+?)\\s*---"
The pattern must be a valid regular expression with one capture group that extracts the group name.
Note: Command-line arguments take precedence over environment variables, which take precedence over configuration file settings.
File Naming Conventions¶
Main Taskfile¶
The main Taskfile can be named (case-sensitive, matches regex [Tt]askfile\.ya?ml):
Taskfile.ymlTaskfile.yamltaskfile.ymltaskfile.yaml
Note: Uppercase variants (Taskfile.*) are preferred and checked first.
Namespace Taskfiles¶
Namespace Taskfiles follow the pattern (case-sensitive, matches regex [Tt]askfile[-_](?P<namespace>\w+)\.ya?ml):
Taskfile-<namespace>.ymlTaskfile-<namespace>.yamlTaskfile_<namespace>.ymlTaskfile_<namespace>.yamltaskfile-<namespace>.ymltaskfile-<namespace>.yamltaskfile_<namespace>.ymltaskfile_<namespace>.yaml
Note: Uppercase variants (Taskfile*) and hyphen separator (-) are preferred.
Examples:
Taskfile-dev.yml→ namespace:devTaskfile_test.yaml→ namespace:testtaskfile-rag.yml→ namespace:ragTaskfile_agent.yml→ namespace:agent
Task Visibility Rules¶
Public Tasks¶
Tasks are public (shown in help) when they have:
- A
descfield - No
internal: trueflag
Internal Tasks¶
Tasks are internal (hidden from help) when:
- Marked with
internal: true - Missing a
descfield
tasks:
_internal:
desc: Internal helper
internal: true # Hidden - marked internal
cmds:
- echo "internal"
no-desc:
# Hidden - no desc field
cmds:
- echo "no description"
Validation¶
taskfile-help automatically validates Taskfiles to ensure they conform to Task version 3 specification.
What is Validated¶
Validation checks the following:
- Version field
- Must exist
-
Must equal
'3'(string, not number or other version) -
Tasks section
- Must exist
-
Must be a dictionary
-
Task structure
- Each task must be a dictionary
- Field type validation:
desc: must be a stringinternal: must be a boolean (trueorfalse)cmds: must be a list or stringdeps: must be a list
Validation Behavior¶
- Always enabled: Validation runs automatically on every parse
- Non-fatal: Warnings are displayed but processing continues
- Clear messages: Explains what's wrong and where
- Fast: Minimal performance impact (~1-2ms per file)
Example Warnings¶
$ taskfile-help
Warning: Invalid version '2', expected '3'
Warning: Task 'build': 'desc' must be a string, got int
Warning: Task 'test': 'internal' must be a boolean, got str
# Tasks are still shown despite warnings
MAIN Task Commands:
Build:
task build - 123
Common Issues¶
Wrong Version¶
# Wrong - number instead of string
version: 3
# Wrong - version 2
version: '2'
# Correct
version: '3'
Invalid Task Fields¶
tasks:
build:
# Wrong - desc must be a string
desc: 123
# Wrong - internal must be boolean
internal: "yes"
# Wrong - deps must be a list
deps: "clean"
# Correct
test:
desc: Run tests
internal: true
deps:
- build
cmds:
- pytest
Stderr Output¶
All validation warnings are written to stderr, so they won't interfere with:
- JSON output (
--json) - Piped commands (
taskfile-help | grep ...) - Redirected output (
taskfile-help > file.txt)
Environment Variables¶
taskfile-help automatically loads environment variables from a .env file in the current directory if it exists. Environment variables set in your shell take precedence over those in the .env file.
NO_COLOR¶
Standard environment variable to disable colored output (see no-color.org):
# Disable colors using standard NO_COLOR
export NO_COLOR=1
taskfile-help
# One-time use
NO_COLOR=1 taskfile-help
TASKFILE_HELP_NO_COLOR¶
Alternative taskfile-help specific variable to disable colors:
# Disable colors
export TASKFILE_HELP_NO_COLOR=true
taskfile-help
# Also accepts: 1, yes
TASKFILE_HELP_NO_COLOR=1 taskfile-help
TASKFILE_HELP_SEARCH_DIRS¶
Set search directories via environment variable (colon-separated):
# Single directory
export TASKFILE_HELP_SEARCH_DIRS=/path/to/project
taskfile-help
# Multiple directories
export TASKFILE_HELP_SEARCH_DIRS=.:/path/to/shared:~/common
taskfile-help
TASKFILE_HELP_GROUP_PATTERN¶
Set a custom group pattern via environment variable:
# Use custom group pattern
export TASKFILE_HELP_GROUP_PATTERN='\s*##\s*(.+?)\s*##'
taskfile-help
# One-time use
TASKFILE_HELP_GROUP_PATTERN='\s*#\s*---\s*(.+?)\s*---' taskfile-help
Using .env File¶
You can also set these in a .env file:
# .env
NO_COLOR=1
TASKFILE_HELP_SEARCH_DIRS=.:../shared
TASKFILE_HELP_GROUP_PATTERN=\s*##\s*(.+?)\s*##
Terminal Behavior¶
taskfile-help respects standard terminal behavior:
- TTY Detection: Automatically detects if output is to a terminal
- Color Support: Colors enabled only when outputting to a TTY
- Pipe Detection: Colors disabled when output is piped or redirected
Search Path Resolution¶
When searching for Taskfiles:
- Absolute paths: Used as-is
- Relative paths: Resolved from current working directory
- Home directory: Tilde expansion supported
- Multiple paths: First match wins
Priority Order¶
Configuration is applied in this order (later overrides earlier):
- Default values
- Configuration file (
taskfile_help.ymlorpyproject.toml) .envfile variables- Environment variables (shell)
- Command-line arguments
Config File Precedence: If both taskfile_help.yml and pyproject.toml exist, taskfile_help.yml takes precedence.
Supported Configuration Options:
- search-dirs:
--search-dirs,TASKFILE_HELP_SEARCH_DIRS, config file - no-color:
--no-color,NO_COLORorTASKFILE_HELP_NO_COLOR, config file - group-pattern:
--group-pattern,TASKFILE_HELP_GROUP_PATTERN, config file
Example:
# .env file
NO_COLOR=1
TASKFILE_HELP_SEARCH_DIRS=.:../shared
TASKFILE_HELP_GROUP_PATTERN=\s*##\s*(.+?)\s*##
# taskfile_help.yml (takes precedence over pyproject.toml)
search-dirs:
- "."
- "../shared"
no-color: false
group-pattern: "\\s*##\\s*(.+?)\\s*##"
# pyproject.toml (used if taskfile_help.yml doesn't exist)
[tool.taskfile-help]
search-dirs = [".", "../shared"]
no-color = false
group-pattern = "\\s*##\\s*(.+?)\\s*##"
# Shell environment variables override .env and config files
export NO_COLOR=1
export TASKFILE_HELP_SEARCH_DIRS=/custom/path
export TASKFILE_HELP_GROUP_PATTERN='\s*#\s*---\s*(.+?)\s*---'
# Command-line arguments override all
taskfile-help --no-color --search-dirs /other/path --group-pattern '\s*#\s*===\s*(.+?)\s*==='
Examples¶
Project with Shared Tasks¶
Using taskfile_help.yml:
Using pyproject.toml:
# Uses both current dir and shared-tasks
taskfile-help
# Override to use only current dir
taskfile-help --search-dirs .
Multi-Repository Setup¶
# Search across multiple repos
taskfile-help --search-dirs ~/repos/main:~/repos/shared:~/repos/tools