Skip to main content

roundtrip_custom_path/
roundtrip_custom_path.rs

1use std::env;
2
3use shellcomp::{InstallRequest, Shell, UninstallRequest, install, uninstall};
4
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}