Allow setting some command-line options with environment variables (#2044)

This commit is contained in:
Greg Shuflin 2024-05-17 16:31:00 -07:00 committed by GitHub
parent 89ccf42ddf
commit 843286f27c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 2 deletions

View File

@ -1395,7 +1395,6 @@ $ just
The process ID is: 420 The process ID is: 420
``` ```
#### String Manipulation #### String Manipulation
- `append(suffix, s)`<sup>master</sup> Append `suffix` to whitespace-separated - `append(suffix, s)`<sup>master</sup> Append `suffix` to whitespace-separated
@ -2514,7 +2513,21 @@ $ just --show polyglot
polyglot: python js perl sh ruby 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 ### Private Recipes

View File

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