pub fn detect_activation(
shell: Shell,
program_name: &str,
) -> Result<ActivationReport>Expand description
Detects how a completion would be activated for the current environment.
Detection inspects the default managed location for the given shell and binary name. For custom
paths, use detect_activation_at_path.
The returned crate::ActivationReport distinguishes the wiring mechanism
(crate::ActivationMode) from current readiness (crate::Availability).
§Errors
Returns crate::Error::Failure when the managed path or startup wiring cannot be inspected
safely.
§Examples
use shellcomp::{Shell, detect_activation};
let report = detect_activation(Shell::Fish, "demo")?;
println!("{report:#?}");Examples found in repository?
examples/inspect_managed_paths.rs (line 6)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 for shell in [Shell::Bash, Shell::Zsh, Shell::Fish] {
5 let path = default_install_path(shell.clone(), "demo")?;
6 let activation = detect_activation(shell.clone(), "demo")?;
7
8 println!("Shell: {shell}");
9 println!("Managed path: {}", path.display());
10 println!("Activation: {activation:#?}");
11 println!();
12 }
13
14 Ok(())
15}