Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
neunenak committed Jun 15, 2023
1 parent 556895a commit 3d7cd62
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ This does not, however, preclude fixing outright bugs, even if doing so might br
There will never be a `just` 2.0. Any desirable backwards-incompatible changes will be opt-in on a per-`justfile` basis, so users may migrate at their leisure.

Features that aren't yet ready for stabilization are gated behind the `--unstable` flag. Features enabled by `--unstable` may change in backwards incompatible ways at any time. The unstable
mode can also be set using the environment variable `JUST_ALLOW_UNSTABLE=true` (any other value for the variable besides `true` is treated as false).
mode can also be set using the environment variable `JUST_UNSTABLE`; any value for this variable other than "false", "0", or the empty string will be treated as enabling unstable mode.


Editor Support
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ use {
clap::{App, AppSettings, Arg, ArgGroup, ArgMatches, ArgSettings},
};

pub(crate) const UNSTABLE_KEY: &str = "JUST_ALLOW_UNSTABLE";

// These three strings should be kept in sync:
pub(crate) const CHOOSER_DEFAULT: &str = "fzf --multi --preview 'just --show {}'";
pub(crate) const CHOOSER_ENVIRONMENT_KEY: &str = "JUST_CHOOSER";
Expand Down Expand Up @@ -572,7 +570,9 @@ impl Config {
};

let unstable = matches.is_present(arg::UNSTABLE)
|| std::env::var_os(UNSTABLE_KEY).map_or(false, |val| val.to_string_lossy() == "true");
|| std::env::var_os("JUST_UNSTABLE").map_or(false, |val| {
!["false", "0", ""].contains(&val.to_string_lossy().as_ref())
});

Ok(Self {
check: matches.is_present(arg::CHECK),
Expand Down
31 changes: 25 additions & 6 deletions tests/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,44 @@ fn set_unstable_true_with_env_var() {
default:
echo 'foo'
"#;
Test::new()

for val in ["true", "some-arbitrary-string"] {
Test::new()
.justfile(justfile)
.args(["--dump", "--dump-format", "json"])
.env("JUST_UNSTABLE", val)
.status(EXIT_SUCCESS)
.stdout_regex("*")
.run();
}
}

#[test]
fn set_unstable_false_with_env_var() {
let justfile = r#"
default:
echo 'foo'
"#;
for val in ["0", "", "false"] {
Test::new()
.justfile(justfile)
.args(["--dump", "--dump-format", "json"])
.env("JUST_ALLOW_UNSTABLE", "true")
.status(EXIT_SUCCESS)
.stdout_regex("*")
.env("JUST_UNSTABLE", val)
.status(EXIT_FAILURE)
.stderr("error: The JSON dump format is currently unstable. Invoke `just` with the `--unstable` flag to enable unstable features.\n")
.run();
}
}

#[test]
fn set_unstable_false_with_env_var() {
fn set_unstable_false_with_env_var_unset() {
let justfile = r#"
default:
echo 'foo'
"#;
Test::new()
.justfile(justfile)
.args(["--dump", "--dump-format", "json"])
.env("JUST_ALLOW_UNSTABLE", "false")
.status(EXIT_FAILURE)
.stderr("error: The JSON dump format is currently unstable. Invoke `just` with the `--unstable` flag to enable unstable features.\n")
.run();
Expand Down

0 comments on commit 3d7cd62

Please sign in to comment.