Skip to main content

install_with_policy

Function install_with_policy 

Source
pub fn install_with_policy(
    request: InstallRequest<'_>,
    activation_policy: ActivationPolicy,
) -> Result<InstallReport>
Expand description

Installs a completion script with explicit activation intent.

This is the opt-in API for callers that want a custom path but still want shellcomp to manage activation when the shell supports it.

ยงExamples

use std::path::PathBuf;

use shellcomp::{ActivationPolicy, InstallRequest, Shell, install_with_policy};

let report = install_with_policy(
    InstallRequest {
        shell: Shell::Bash,
        program_name: "demo",
        script: b"complete -F _demo demo\n",
        path_override: Some(PathBuf::from("/tmp/demo.bash")),
    },
    ActivationPolicy::AutoManaged,
)?;

println!("{report:#?}");