Don't require justfile to print completions (#596)

Currently, the `--completions` subcommand will fail if there is no
justfile present. A justfile isn't needed to print completions, so fix
this.
This commit is contained in:
Casey Rodarmor 2020-02-20 06:07:25 -08:00 committed by GitHub
parent c12c683286
commit dcc98abdf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -388,6 +388,10 @@ impl Config {
return self.init(); return self.init();
} }
if let Completions { shell } = self.subcommand {
return Self::completions(&shell);
}
let search = let search =
Search::find(&self.search_config, &self.invocation_directory).eprint(self.color)?; Search::find(&self.search_config, &self.invocation_directory).eprint(self.color)?;
@ -414,7 +418,6 @@ impl Config {
match &self.subcommand { match &self.subcommand {
Dump => Self::dump(justfile), Dump => Self::dump(justfile),
Completions { shell } => Self::completions(&shell),
Evaluate { overrides } => self.run(justfile, &search, overrides, &Vec::new()), Evaluate { overrides } => self.run(justfile, &search, overrides, &Vec::new()),
Run { Run {
arguments, arguments,
@ -423,7 +426,7 @@ impl Config {
List => self.list(justfile), List => self.list(justfile),
Show { ref name } => Self::show(&name, justfile), Show { ref name } => Self::show(&name, justfile),
Summary => Self::summary(justfile), Summary => Self::summary(justfile),
Edit | Init => unreachable!(), Completions { .. } | Edit | Init => unreachable!(),
} }
} }

View File

@ -1,12 +1,16 @@
use std::process::Command; use std::process::Command;
use executable_path::executable_path; use executable_path::executable_path;
use tempfile::tempdir;
#[test] #[test]
fn output() { fn output() {
let tempdir = tempdir().unwrap();
let output = Command::new(executable_path("just")) let output = Command::new(executable_path("just"))
.arg("--completions") .arg("--completions")
.arg("bash") .arg("bash")
.current_dir(tempdir.path())
.output() .output()
.unwrap(); .unwrap();