Skip to content

Easily add permission flags to CLIs using Clap

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

clap-rs/clap-permission-flag

clap-permission-flag

crates.io version build status downloads docs.rs docs

Drop permissions of a CLI using structopt.

Usage

use clap::Parser;

#[derive(Debug, Parser)]
struct Cli {
    #[clap(flatten)]
    permission: clap_permission_flag::Permission,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let args = Cli::parse();
    args.permission.drop()?;
    Ok(())
}

This crate depends on Unix features - on other platforms a stub implementation which has no flags and always succeeds if used.

Example Output

clap-permission-flag 0.3.0
Yoshua Wuyts <[email protected]>
Drop permissions of a CLI using structopt

USAGE:
    main [OPTIONS]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --chroot <chroot>    Change the process root directory
    -g, --group <group>      Change the process group
    -u, --user <user>        Change the process user

Installation

$ cargo add clap-permission-flag

Since --chroot may not be suitable for all applications, it is behind the chroot feature and must be enabled explicitly:

[dependencies.clap-permission-flag]
version = "0.3"
features = ["chroot"]

See Also

License

MIT OR Apache-2.0

About

Easily add permission flags to CLIs using Clap

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages