Skip to content
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

Support justfile-wide configuration options #361

Closed
casey opened this issue Oct 11, 2018 · 4 comments
Closed

Support justfile-wide configuration options #361

casey opened this issue Oct 11, 2018 · 4 comments

Comments

@casey
Copy link
Owner

casey commented Oct 11, 2018

@slmjkdbtl requested the ability to set the default interpreter for the entire justfile, which seems reasonable. It seems like some syntax for setting justfile-wide configuration options would be useful, and this could be such option.

@casey casey added this to the soon milestone Apr 16, 2019
@casey
Copy link
Owner Author

casey commented Apr 17, 2019

I'm planning on adding a new set top-level item for justfile-wide configuration options.

I'm open to adding anything that's useful, but allowing users to set an interpreter on a per-justfile basis seems important enough that adding settings feels worth it just for that.

Setting the shell will be done with:

set shell := ["sh", "-cu"]

Of course, using a more exotic interpreter will be possible:

set shell := ["python", "-c"]

Because this particular setting controls how backticks are executed, it seems wise to prohibit backticks in values:

set shell := [`which python`, "-c"] 

Although it would be possible to change the shell after evaluating the RHS of set shell :=, it's a bit confusing, so I'm inclined to disallow it unless it's a strongly desired feature.

The [ ... ] surrounded , delimited syntax for lists is verbose, but serves to make it easy to extend the parser in the future. In general, I find that un-delimited/whitespace-delimited syntax makes extensions tricky and ambiguity more likely, so I'll probably stick to relatively verbose syntax extensions in the future.

In the PR that adds this feature, I'll also deprecate = in assignments, exports, and aliases, so as to eliminate ambiguity in the parser. A = in these constructs will be a warning for some period of time, and will be made an error in a future minor version bump. (Since we're still not at 1.0 yet, we can make backwards incompatible changes without bumping the major version.)

The new spelling for these items will be:

foo := "bar"
export bar := "baz"
alias b := build

This PR will close a few issues:

#161: Remove dependency on sh – When I originally wrote just, I wanted to eventually switch from using sh to using a tightly integrated shell written in rust. I am now not entirely convinced that this is a good idea, but perhaps more importantly, I think that doing this well is nontrivial, to say the least. Adding set shell := ... will allow users to use whatever shell they like, which greatly improves just's cross platform story, which removes a lot of the need to move away from sh

#326: Support cmd.exe on windows – Windows users will be able to use cmd.exe or powershell as they see fit.

#379: Assignments and aliases conflicts with default arguments – With the introduction of := syntax and deprecation of = syntax, (except for default arguments, where it will continue to be accepted), this issue will also be on its way to being fixed

@casey
Copy link
Owner Author

casey commented Apr 17, 2019

Note to self: Should also deprecate --shell, since its behavior doesn't match the --shell setting.

@casey casey modified the milestones: soon, eventually, 1.0 May 27, 2019
@casey casey modified the milestones: 1.0, soon Nov 11, 2019
@casey
Copy link
Owner Author

casey commented Nov 13, 2019

I just released v0.5.0, which includes the ability to set the shell used for recipes and backticks on a justfile-wide basis. This gives just rudimentary support for cmd.exe and powershell, by adding set shell := ["cmd.exe", "/c"] or set shell := ["powershell", "-c"]. (see #530 and the readme for more details)

I hope the new set shell := ... feature is useful! Let me know if you have problems with it, or have suggestions for improving it.

@casey casey closed this as completed Nov 13, 2019
@casey
Copy link
Owner Author

casey commented Nov 13, 2019

Also, now that there's a set language construct, adding new settings should be relatively straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant