From dcc98abdf88aff4ac4d0daa0ae4a45c4af905b6b Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 20 Feb 2020 06:07:25 -0800 Subject: [PATCH] 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. --- src/config.rs | 7 +++++-- tests/completions.rs | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index 9c6dadc..48296bb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -388,6 +388,10 @@ impl Config { return self.init(); } + if let Completions { shell } = self.subcommand { + return Self::completions(&shell); + } + let search = Search::find(&self.search_config, &self.invocation_directory).eprint(self.color)?; @@ -414,7 +418,6 @@ impl Config { match &self.subcommand { Dump => Self::dump(justfile), - Completions { shell } => Self::completions(&shell), Evaluate { overrides } => self.run(justfile, &search, overrides, &Vec::new()), Run { arguments, @@ -423,7 +426,7 @@ impl Config { List => self.list(justfile), Show { ref name } => Self::show(&name, justfile), Summary => Self::summary(justfile), - Edit | Init => unreachable!(), + Completions { .. } | Edit | Init => unreachable!(), } } diff --git a/tests/completions.rs b/tests/completions.rs index 0121e1d..4b172cf 100644 --- a/tests/completions.rs +++ b/tests/completions.rs @@ -1,12 +1,16 @@ use std::process::Command; use executable_path::executable_path; +use tempfile::tempdir; #[test] fn output() { + let tempdir = tempdir().unwrap(); + let output = Command::new(executable_path("just")) .arg("--completions") .arg("bash") + .current_dir(tempdir.path()) .output() .unwrap();