use predicates::prelude::*;
use tempfile::TempDir;
use crate::cases::support::{treeboot, write_file};
pub(crate) fn completions_supported_shells_should_emit_scripts() {
for shell in ["bash", "zsh", "fish", "powershell", "elvish"] {
treeboot()
.args(["completions", shell])
.assert()
.success()
.stderr(predicate::str::is_empty())
.stdout(predicate::str::contains("treeboot"));
}
}
pub(crate) fn completions_unsupported_shell_should_exit_with_usage_error() {
treeboot()
.args(["completions", "nu"])
.assert()
.code(2)
.stdout(predicate::str::is_empty())
.stderr(predicate::str::is_empty().not());
}
pub(crate) fn completions_should_not_require_git_or_config_discovery() {
let dir = TempDir::new().expect("tempdir should be created");
write_file(&dir.path().join(".treeboot.toml"), "invalid toml = [\n");
treeboot()
.args(["completions", "fish"])
.env("TREEBOOT_STRICT", "not-a-bool")
.current_dir(dir.path())
.assert()
.success()
.stderr(predicate::str::is_empty())
.stdout(predicate::str::contains("treeboot"));
}