Skip to main content

uninstall

Function uninstall 

Source
pub fn uninstall(request: UninstallRequest<'_>) -> Result<RemoveReport>
Expand description

Removes a previously managed completion script and any managed activation wiring.

When path_override is set, legacy behavior removes only that file path for non-default custom targets. If the override is equal to the shell’s managed default path, uninstall keeps the default cleanup semantics for that shell.

This function is idempotent. Removing an already absent completion file returns crate::FileChange::Absent rather than failing.

§Errors

Returns crate::Error::Failure for structured operational failures such as unresolved managed paths or unwritable shell profile files.

§Examples

use shellcomp::{Shell, UninstallRequest, uninstall};

let report = uninstall(UninstallRequest {
    shell: Shell::Bash,
    program_name: "demo",
    path_override: None,
})?;

assert_eq!(report.shell, Shell::Bash);
Examples found in repository?
examples/roundtrip_custom_path.rs (lines 16-20)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6    let demo_path = env::temp_dir().join(format!("demo-roundtrip-{}.fish", std::process::id()));
7    let script = b"complete -c demo -f\n";
8
9    let install_report = install(InstallRequest {
10        shell: Shell::Fish,
11        program_name: "demo",
12        script,
13        path_override: Some(demo_path.clone()),
14    })?;
15
16    let uninstall_report = uninstall(UninstallRequest {
17        shell: Shell::Fish,
18        program_name: "demo",
19        path_override: Some(demo_path.clone()),
20    })?;
21
22    println!("Installed and removed a custom-path completion file.");
23    println!("Path: {}", demo_path.display());
24    println!("Install report:\n{install_report:#?}");
25    println!("Uninstall report:\n{uninstall_report:#?}");
26    Ok(())
27}