Suggestion: Listing of groups
In v.1.29.1, I can do something like just --list <submodule_name> and see the recipes for a given submodule.
It would be great if I could do something along the lines of just --list <group> to see all the available recipes for a certain group.
The actual syntax should indeed be considered as simply stating a group could name-clash with submodule names.
I am unsure if the interface is stable, but I personally enjoy a git similar approch with just --group <group_name>, but to unify a common interface then I guess also submodules should be just --submodule <submodule_name>.
just --group <group_name> is an option, although I think it would be unfortunate if we added another subcommand for listing recipes, and didn't reuse --list, since they would both be such similar commands. Some way of disambiguating would likely be awkward though, for example a prefix: just --list group:NAME / just --list @NAME.
I think it would probably be fine to just use just --list, and if there is a conflict between a group and a submodule, display one or the other, probably defaulting to the submodule. If users don't want that behavior, then it's easy enough to rename either the submodule or the group so that it's unambiguous.
Excellent idea! I'd like to mark tasks which need to be run in CI via [group('ci')] and it'd be really useful to programmatically get all tasks that belong to a given group.
Edit: found a workaround: just --dump --dump-format=json and then manually checking for groups. (just in case anyone finds this comment via search).
+1 to this request.
For our use case, we have a bunch of commands and want to only show the "main" group by default.
found a workaround:
--dump --dump-format=json
And to really make it nifty, some jq magic will print things out:
_default:
@just --dump --dump-format=json | jq '.recipes | to_entries[] | select(.value.attributes | any(.group == "main")) | .key'
[group("main")]
ci:
[group("main")]
[group("python")]
format-python:
[group("python")]
test-python:
$ just
"ci"
"format-python"
I admit, I used gemini to write that jq query, so who knows if it's actually any good 🤣
Here's a slightly better workaround implementation. I'm still working on the blue comments haha - seems column doesn't like terminal color codes.
_default:
@scripts/_just_list.sh
#!/bin/bash
# scripts/_just_list.sh
# List only a subset of 'just' commands.
# This can be removed when https://github.com/casey/just/issues/2195 is implemented.
if ! which jq >/dev/null; then
echo "Need to install 'jq'."
sudo apt install jq
fi
GROUP="main"
BOLD_YELLOW="\033[1;93m"
RESET="\033[0;0m"
echo "Available recipes:"
echo -e " ${BOLD_YELLOW}[${GROUP}]${RESET}"
just --dump --dump-format=json |
jq '.recipes | to_entries[] | select(.value.attributes | any(.group == "main")) | "\(.key)~# \(.value.doc // "")"' |
tr -d '"' |
sed 's/^/ /g' |
column -t -s "~"
echo
echo "Additional recipes are available. To see all, run:"
echo " just --list"