Skip to content

Conversation

@rpunkfu
Copy link

@rpunkfu rpunkfu commented Nov 9, 2025

Hi, this is a feature I've really wanted, so I decided to implement it over the last two weekends whenever I had some free time.
I hope it meets your standards and we can get it merged swiftly! :)

I've added an entry to README.md explaining the usage, so I'm just going to refer to it below, instead of repeating myself.

Recipe Flags

In addition to parameters, recipes may have flags.
Flags are named optional arguments that use --flag syntax and can appear anywhere in the argument list:

build target --release --jobs='4':
  cargo build {{ if release == "true" { "--release" } else { "" } }} --jobs={{jobs}} --target={{target}}

Flags come in two forms:

Switch flags are boolean flags that don't take a value.
When present on the command line, they're set to "true", otherwise "false":

deploy --dry-run:
  @echo "Dry run: {{dry-run}}"
$ just deploy --dry-run
Dry run: true
$ just deploy
Dry run: false

Value flags take a value and must have a default, specified with =:

serve --port='8080':
  python -m http.server {{port}}
$ just serve --port=3000
python -m http.server 3000
$ just serve
python -m http.server 8080

Flags can be passed in any order and can be mixed with positional parameters:

$ just build x86_64-linux --release --jobs=8
$ just build x86_64-linux --jobs=8 --release

Flag names are converted to variable names by preserving the exact characters,
allowing hyphens in variable names when accessed via {{flag-name}}:

test --dry-run:
  @echo "Dry run mode: {{dry-run}}"

To pass a value that looks like a flag as a positional argument, use -- to stop flag parsing:

$ just cmd -- --not-a-flag

Fixes: #476

@rpunkfu rpunkfu force-pushed the feature/positional-flags branch from 6bf6538 to 65a7072 Compare November 20, 2025 09:58
@rpunkfu rpunkfu force-pushed the feature/positional-flags branch from 65a7072 to 56f8538 Compare November 25, 2025 19:35
@rpunkfu
Copy link
Author

rpunkfu commented Nov 25, 2025

@casey Any chance to get some feedback on this?

@casey
Copy link
Owner

casey commented Dec 28, 2025

Hey, sorry to close this, but I wound up implementing it myself in #3026.

I left a comment in another PR which I also shamefully did not review and wound up closing with details on the implementation, and why I went a different way: #2806 (comment)

@casey casey closed this Dec 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add flags and options

2 participants