Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/clap-rs/clap-permission-flag
Easily add permission flags to CLIs using Clap
https://github.com/clap-rs/clap-permission-flag
clap cli rust
Last synced: 9 days ago
JSON representation
Easily add permission flags to CLIs using Clap
- Host: GitHub
- URL: https://github.com/clap-rs/clap-permission-flag
- Owner: clap-rs
- License: apache-2.0
- Created: 2018-08-06T19:33:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-07T08:18:23.000Z (12 months ago)
- Last Synced: 2024-05-28T16:27:24.377Z (6 months ago)
- Topics: clap, cli, rust
- Language: Rust
- Homepage:
- Size: 57.6 KB
- Stars: 9
- Watchers: 9
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE-APACHE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# clap-permission-flag
[![crates.io version][1]][2] [![build status][3]][4]
[![downloads][5]][6] [![docs.rs docs][7]][8]Drop permissions of a CLI using structopt.
- [Documentation][8]
- [Crates.io][2]## Usage
```rust,no_run
use clap::Parser;#[derive(Debug, Parser)]
struct Cli {
#[clap(flatten)]
permission: clap_permission_flag::Permission,
}fn main() -> Result<(), Box> {
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
```txt
clap-permission-flag 0.3.0
Yoshua Wuyts
Drop permissions of a CLI using structoptUSAGE:
main [OPTIONS]FLAGS:
-h, --help Prints help information
-V, --version Prints version informationOPTIONS:
--chroot Change the process root directory
-g, --group Change the process group
-u, --user Change the process user
```## Installation
```sh
$ 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:```toml
[dependencies.clap-permission-flag]
version = "0.3"
features = ["chroot"]
```## See Also
- https://github.com/jedisct1/rust-privdrop
## License
[MIT](./LICENSE-MIT) OR [Apache-2.0](./LICENSE-APACHE)
[1]: https://img.shields.io/crates/v/clap-permission-flag.svg?style=flat-square
[2]: https://crates.io/crates/clap-permission-flag
[3]: https://img.shields.io/travis/rust-clique/clap-permission-flag.svg?style=flat-square
[4]: https://travis-ci.org/rust-clique/clap-permission-flag
[5]: https://img.shields.io/crates/d/clap-permission-flag.svg?style=flat-square
[6]: https://crates.io/crates/clap-permission-flag
[7]: https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square
[8]: https://docs.rs/clap-permission-flag