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

Set just flags through environment variables #2044

Merged
merged 5 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,6 @@ $ just
The process ID is: 420
```


#### String Manipulation

- `append(suffix, s)`<sup>master</sup> Append `suffix` to whitespace-separated
Expand Down Expand Up @@ -2514,7 +2513,21 @@ $ just --show polyglot
polyglot: python js perl sh ruby
```

Run `just --help` to see all the options.
Some command-line options can be set with environment variables. For example:

```sh
$ export JUST_UNSTABLE=1
$ just
```

Is equivalent to:

```sh
$ just --unstable
```

Consult `just --help` to see which options can be set from environment
variables.

### Private Recipes

Expand Down
7 changes: 7 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ impl Config {
.arg(
Arg::new(arg::COLOR)
.long("color")
.env("JUST_COLOR")
.action(ArgAction::Set)
.value_parser(PossibleValuesParser::new(arg::COLOR_VALUES))
.default_value(arg::COLOR_AUTO)
Expand All @@ -184,6 +185,7 @@ impl Config {
.arg(
Arg::new(arg::COMMAND_COLOR)
.long("command-color")
.env("JUST_COMMAND_COLOR")
.action(ArgAction::Set)
.value_parser(PossibleValuesParser::new(arg::COMMAND_COLOR_VALUES))
.help("Echo recipe lines in <COMMAND-COLOR>"),
Expand All @@ -193,6 +195,7 @@ impl Config {
Arg::new(arg::DRY_RUN)
.short('n')
.long("dry-run")
.env("JUST_DRY_RUN")
.action(ArgAction::SetTrue)
.help("Print what just would do without doing it")
.conflicts_with(arg::QUIET),
Expand Down Expand Up @@ -257,6 +260,7 @@ impl Config {
Arg::new(arg::JUSTFILE)
.short('f')
.long("justfile")
.env("JUST_JUSTFILE")
.action(ArgAction::Set)
.value_parser(value_parser!(PathBuf))
.help("Use <JUSTFILE> as justfile"),
Expand All @@ -265,6 +269,7 @@ impl Config {
Arg::new(arg::QUIET)
.short('q')
.long("quiet")
.env("JUST_QUIET")
.action(ArgAction::SetTrue)
.help("Suppress all output")
.conflicts_with(arg::DRY_RUN),
Expand Down Expand Up @@ -324,13 +329,15 @@ impl Config {
Arg::new(arg::VERBOSE)
.short('v')
.long("verbose")
.env("JUST_VERBOSE")
.action(ArgAction::Count)
.help("Use verbose output"),
)
.arg(
Arg::new(arg::WORKING_DIRECTORY)
.short('d')
.long("working-directory")
.env("JUST_WORKING_DIRECTORY")
.action(ArgAction::Set)
.value_parser(value_parser!(PathBuf))
.help("Use <WORKING-DIRECTORY> as working directory. --justfile must also be set")
Expand Down