You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(First of all, thank you for creating this wonderful command runner. After spending a long time debating between the various alternates to Makefile, writing my own shell scripts, or what, I discovered just a brief while ago, and it immediately became my favorite.)
As the title says, I would like to be able to organize recipes into groups, similar to GitHub's gh command. Example usage:
# user group
just user list
just user show NAME
just user create NAME
just user delete NAME
# product group
just product list
just product show NAME
just product create NAME
just product delete NAME
# etc.
As for how the syntax or mechanism for achieving this inside justfiles might look like, there could be multiple ways for doing so, and I suppose deciding which one is best might need some discussion among the developers and community, but I'm going to both humor you and give you a serious suggestion by telling you the following story.
I asked ChatGPT: "I want to write a just file where commands are divided into groups, where each group contains sub-commands. Is there a particular way that is considered idiomatic for doing so in just files?"
In its sheer magnificence, ChatGPT hallucinated the following answer:
Yes, there is a common way to organize commands into groups with sub-commands in a Justfile. Here's an example of how you can achieve this:
# Define a group of tasks with a common prefix# Example: just build.app# Example: just build.librarybuild:# The build group has its own set of sub-tasks# Example: just build.app.android
app.android:
echo "Building Android app"
app.ios:
echo "Building iOS app"
library:
echo "Building library"
Initially wondering whether a feature like this actually exists and I simply missed it, I pasted it into a justfile and invoked it, only to get some syntax errors...
That said, I think ChatGPT's entertaining hallucination seriously seems like a nice idea, as it would make writing justfiles with command groups very simple, natural and easy as a breeze, at least from the perspective of the user.
However, from the perspective of Just's developers, it might be troublesome, as determining that whether something is a recipe or a group relies on matching the first line of the indented block against recipe definition syntax and then checking if the subsequent line is indented, and unfortunately this is error-prone and can result in confusing errors for the user.
Fortunately, the ambiguity can be alleviated by requiring that groups headings are marked in some unambiguous way. For example:
Also note that ChatGPT's suggestion involves using a period between the group name and the command name in the command-line. While personally I prefer not to have it that way from a pure stylistic perspective, but from an implementation perspective, it might simplify things a great deal for both Just's developers and even the users, as you no longer have to wonder if a command-line like just build android means "Invoke the two recipes build and android" or "Invoke the android recipe from the build group".
I have another suggestion that might make implementing groups even simpler, which is allowing periods in recipe names and making it so that the shell completion only lists commands in the current nesting level. For example, if we have recipes called build.android, build.ios, test.android, test.ios, then typing just and pressing tab would just list only build. and test., but if the command-line is just build., then the completion function would list build.android and build.ios, and this would work with an arbitrary number of nesting levels.
If done like this, it would be much easier to implement, and as a bonus, it would allow offering an extra feature, which is that unless a recipe called build is explicitly defined, then invoking just build would automatically invoke all recipes with the build. prefix.
As you can see, there are various ways to do this, and deciding which one is best might need some discussion, but in any case personally I think it would be pretty nice to have in one form or another.
Thank you in advance.
The text was updated successfully, but these errors were encountered:
(First of all, thank you for creating this wonderful command runner. After spending a long time debating between the various alternates to
Makefile
, writing my own shell scripts, or what, I discoveredjust
a brief while ago, and it immediately became my favorite.)As the title says, I would like to be able to organize recipes into groups, similar to GitHub's
gh
command. Example usage:As for how the syntax or mechanism for achieving this inside justfiles might look like, there could be multiple ways for doing so, and I suppose deciding which one is best might need some discussion among the developers and community, but I'm going to both humor you and give you a serious suggestion by telling you the following story.
I asked ChatGPT: "I want to write a just file where commands are divided into groups, where each group contains sub-commands. Is there a particular way that is considered idiomatic for doing so in just files?"
In its sheer magnificence, ChatGPT hallucinated the following answer:
Initially wondering whether a feature like this actually exists and I simply missed it, I pasted it into a justfile and invoked it, only to get some syntax errors...
That said, I think ChatGPT's entertaining hallucination seriously seems like a nice idea, as it would make writing justfiles with command groups very simple, natural and easy as a breeze, at least from the perspective of the user.
However, from the perspective of Just's developers, it might be troublesome, as determining that whether something is a recipe or a group relies on matching the first line of the indented block against recipe definition syntax and then checking if the subsequent line is indented, and unfortunately this is error-prone and can result in confusing errors for the user.
Fortunately, the ambiguity can be alleviated by requiring that groups headings are marked in some unambiguous way. For example:
Also note that ChatGPT's suggestion involves using a period between the group name and the command name in the command-line. While personally I prefer not to have it that way from a pure stylistic perspective, but from an implementation perspective, it might simplify things a great deal for both Just's developers and even the users, as you no longer have to wonder if a command-line like
just build android
means "Invoke the two recipesbuild
andandroid
" or "Invoke theandroid
recipe from thebuild
group".I have another suggestion that might make implementing groups even simpler, which is allowing periods in recipe names and making it so that the shell completion only lists commands in the current nesting level. For example, if we have recipes called
build.android
,build.ios
,test.android
,test.ios
, then typingjust
and pressing tab would just list onlybuild.
andtest.
, but if the command-line isjust build.
, then the completion function would listbuild.android
andbuild.ios
, and this would work with an arbitrary number of nesting levels.If done like this, it would be much easier to implement, and as a bonus, it would allow offering an extra feature, which is that unless a recipe called
build
is explicitly defined, then invokingjust build
would automatically invoke all recipes with thebuild.
prefix.As you can see, there are various ways to do this, and deciding which one is best might need some discussion, but in any case personally I think it would be pretty nice to have in one form or another.
Thank you in advance.
The text was updated successfully, but these errors were encountered: