Skip to content

Commit

Permalink
Use just --show in default chooser (#1539)
Browse files Browse the repository at this point in the history
  • Loading branch information
fzdwx authored Jan 28, 2023
1 parent 941a40e commit 5f9ac39
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ temptree = "0.2.0"
which = "4.0.0"
yaml-rust = "0.4.5"

[lib]
doctest = false

[[bin]]
path = "src/main.rs"
name = "just"
test = false

[features]
# No features are active by default.
default = []
Expand Down
2 changes: 1 addition & 1 deletion man/just.1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Run `\-\-fmt` in 'check' mode. Exits with 0 if justfile is formatted correctly.
.TP
\fB\-\-choose\fR
Select one or more recipes to run using a binary. If `\-\-chooser` is not passed the
chooser defaults to the value of $JUST_CHOOSER, falling back to `fzf`
chooser defaults to the value of $JUST_CHOOSER, falling back to `fzf --preview 'just --show {}'`
.TP
\fB\-\-clear\-shell\-args\fR
Clear shell arguments
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
};

// These three strings should be kept in sync:
pub(crate) const CHOOSER_DEFAULT: &str = "fzf";
pub(crate) const CHOOSER_DEFAULT: &str = "fzf --preview 'just --show {}'";
pub(crate) const CHOOSER_ENVIRONMENT_KEY: &str = "JUST_CHOOSER";
pub(crate) const CHOOSE_HELP: &str = "Select one or more recipes to run using a binary. If \
`--chooser` is not passed the chooser defaults to the value \
Expand Down
5 changes: 4 additions & 1 deletion tests/choose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ fn invoke_error_function() {
echo bar
",
)
.stderr_regex("error: Chooser `/ -cu fzf` invocation failed: .*\n")
.stderr_regex(
r"error: Chooser `/ -cu fzf --preview 'just --show \{\}'` invocation failed: .*\n",
)
.status(EXIT_FAILURE)
.shell(false)
.args(["--shell", "/", "--choose"])
Expand Down Expand Up @@ -213,6 +215,7 @@ fn default() {

let output = Command::new(executable_path("just"))
.arg("--choose")
.arg("--chooser=fzf")
.current_dir(tmp.path())
.env("PATH", path)
.output()
Expand Down

0 comments on commit 5f9ac39

Please sign in to comment.