Feature Request: Add Dynamic Prefix Aliases
- Dominant language
- Rust
- Stars
- 35.8k
- Forks
- 846
- Avg merge
- 27m
- Merged PRs (30d)
- 3
Description
As of now, in order to use alias, you need to define them in the justfile.
```just
alias b := build
```
In my opinion, one main use of alias is to provide a shorter way to invoke the same command.
Hence, I am wonder if `just` would want to support writing short forms without even being explicitly defined in the just file.
```sh
just build # original command
just b # valid command
just bu # also valid
just bui # also valid
just buil # also valid
```
In my opinion dynamic aliases should never appear on `just --list`,
since it is not explicit and would completely clutter the output.
The format of alias would be `[unique command prefix][any amount of the rest of the command (optional)]`,
hence when there are 3 jobs "build", "check", "compile", the following will happen:
```sh
just b # runs `just build`
just c # produces an error, preferably outputting the 2 matched commands as part of a correction hint
just ch # runs `just check`
just co # runs `just compile`
```
In order to work with existing defined alias, I am thinking of treating alias as also valid commands,
and preform exact matches before checking for dynamic prefix matches.
So for the following justfile:
```just
alias test := check
alias c := challenge
challenge:
# run authentication challenge step
check:
# run check steps
```
The following will happen:
```sh
just c # matches exact alias "c", runs challenge
just ch # does not match any exact alias or tasks, output `non-unique error, see: challenge, check`
just che # does not match any exact alias or tasks, but matches first unique prefix for task: check, runs check
just t # does not match any exact alias or tasks, but matches first unique prefix for alias: test, runs check
```
I think it would beneficial to include this as part of just,
since short forms can be used without defining an explicit alias,
and conflict in matching can be resolve quite clearly.
Thank you for making `just`!
Contributor guide
Research direction
The issue names no files or tests. Start by tracing just's command and alias resolution, then add coverage for exact aliases, unique prefixes, ambiguous matches, and --list behavior; done means the specified examples behave consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100