Loads config and hosts for gh CLI in Rust.
toml
[dependencies]
gh-config = "0.2"
```rust use std::error::Error; use gh_config::*;
fn main() -> Result<(), Box
match hosts.get(GITHUB_COM) {
Some(host) => println!("Token for github.com: {}", host.oauth_token),
_ => eprintln!("Token not found."),
}
Ok(())
} ```
gh-config-rs is a hybrid crate that can be used as a library or a CLI. To use as a CLI, can be installed using the command line below:
shell
cargo install gh-config --features=cli
Lists all configuration in YAML:
shell
gh-config config show
Uses JSON instead:
shell
gh-config --json config show
Uses custom path of config.yaml instead of default:
shell
gh-config --path /path/to/config.yaml config show
Gets an authentication for github.com:
shell
gh-config authn get github.com
Outputs only the OAuth token instead:
shell
gh-config authn get --token-only github.com