Positional Arguments
Positional arguments let you pass values to recipes without named parameters.
Basic Usage
Section titled “Basic Usage”Access arguments with {{$1}}, {{$2}}, etc.:
task greet: echo "Hello, {{$1}}!"$ jake greet WorldHello, World!Multiple Arguments
Section titled “Multiple Arguments”Access each argument by position:
task deploy: echo "Deploying {{$1}} to {{$2}}"$ jake deploy v1.0.0 productionDeploying v1.0.0 to productionAll Arguments
Section titled “All Arguments”Use {{$@}} to access all arguments at once:
task echo-all: echo "Arguments: {{$@}}"$ jake echo-all a b c dArguments: a b c dWith Named Parameters
Section titled “With Named Parameters”Positional arguments work alongside named parameters:
task deploy env="staging": echo "Deploying to {{env}} with args: {{$@}}"$ jake deploy env=production extra-flagDeploying to production with args: extra-flagForwarding to Commands
Section titled “Forwarding to Commands”Pass all arguments to another command:
task npm: npm {{$@}}$ jake npm install lodash# Runs: npm install lodashConditional Logic on Arguments
Section titled “Conditional Logic on Arguments”Positional args ({{$1}}, {{$2}}) do not work inside @if condition expressions. Condition strings are not pre-expanded, so eq("{{$1}}", "") looks up a variable literally named $1 (not found), always resolves to empty string, and makes the condition useless.
Use named parameters instead. Named parameters are stored in the variables map and work correctly with all condition functions:
# Works: named parameter used in conditiontask greet name="stranger": @if eq(name, stranger) echo "No name given, using default" @else echo "Hello, {{name}}!" @end$ jake greetNo name given, using default
$ jake greet name=AliceHello, Alice!Named parameters also support eq(), neq(), exists(), and any other condition function.
Syntax Notes
Section titled “Syntax Notes”- Use
{{$1}},{{$2}}, etc. for specific positions (1-indexed) - Use
{{$@}}for all arguments as a single string - Do not add spaces inside braces -
{{$1}}works,{{ $1 }}does not - Arguments are whitespace-separated on the command line