-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update suggested default recipe to include a justfile option #1296
Conversation
Good idea! |
README.md
Outdated
``` | ||
|
||
Note that the `--justfile {{justfile()}}` above is needed to make sure the listed recipes are from the current `justfile`. Without it, if you executed `just -f /some/distant/justfile` or `just -f ./non-standard-justfile`, the plain `just --list` call in the `default` recipe would not use the file you provided. It would try to find a justfile in your current path, maybe even resulting in a `No justfile found` error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@casey Is this better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is just -f /some/distant/justfile
a problem? I think just will switch its working directory and find the justfile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the case of that .j
alias, the directory is already set. I don't think there's other solution to combine both (the alias and the list recipe, I mean).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more generic feature that just
may need is an alternative to this $(MAKE) $(MFLAGS)
for calling a "sub" just
.
Maybe, a just()
function could be equivalent to {{just_executable()}} --justfile {{justfile()}}
. Then, recommend that any recursive just calls are made with {{just()}}
instead of plainly just
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely need something like. I want some way of running a just command in the middle of a recipe, but we haven't figured out the syntax yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having trouble reproducing the behavior you mentioned. I created a justfile in foo/.justfile, which has just --list
in the first recipe, calling just -f foo/.justfile
seems to work, it successfully calls just and lists the recipes in the justfile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output below may help.
Notice that:
- the
jj
alias includes a-d .
option, as is suggested at https://just.systems/man/en/chapter_63.html#forwarding-alias; - all executions of
jj
did echojust --list
, meaning it's running the recipe from~/justfile
- when
pwd
is inside my home (e.g.~/src/
),jj
works as intended. - when
pwd
is outside of~
, I get aNo justfile found
coming from the default recipe; - when
pwd
is in a directory with another justfile, it lists recipes from that directory instead.
The only way I see to prevent the unintended behavior (4 and 5) is by changing the recipe to say just --justfile {{justfile()}} --list
.
$ cat ~/justfile
default:
just --list
pwd:
pwd
$ type jj
jj is aliased to `just -f ~/justfile -d .'
$ cd ~/src
$ jj
just --list
Available recipes:
default
pwd
$ cd /
$ jj
just --list
error: No justfile found
error: Recipe `default` failed on line 2 with exit code 1
$ cd ~/src/jp/just/
$ jj
just --list
Available recipes:
build
build-book
changes # add git log messages to changelog
check
c # alias for `check`
…
a67bca6
to
967cb14
Compare
Ah, okay, sorry, I misunderstood. I thought that it was just the |
967cb14
to
2e4d582
Compare
@casey I'm cool with that, too. The current example would work as is for the majority of cases, and there's value in keeping them simple. I updated the code with that now. |
Nice! I added the |
This is an update to documentation, with a better recipe suggestion.
I had a
justfile
with the following content:Then, I tried to run
.j
(aliased tojust -f ~/.justfile -d .
as suggested at User justfiles), and got the following error:Running
.j pwd
worked. The issue if that.j
would run thedefault
recipe, which executesjust --list
without passing the--justfile
option again.