Crates.io | gh-config |
lib.rs | gh-config |
version | 0.4.1 |
source | src |
created_at | 2022-07-23 13:30:16.66401 |
updated_at | 2024-09-29 06:31:14.184308 |
description | Loads config and hosts for gh CLI. |
homepage | https://github.com/siketyan/gh-config-rs |
repository | https://github.com/siketyan/gh-config-rs.git |
max_upload_size | |
id | 631407 |
size | 67,222 |
Loads config and hosts for gh CLI in Rust.
[dependencies]
gh-config = "0.4.0"
use std::error::Error;
use gh_config::*;
fn main() -> Result<(), Box<dyn Error>> {
let config = Config::load()?;
let hosts = Hosts::load()?;
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:
cargo install gh-config --features=cli
Lists all configuration in YAML:
gh-config config show
Uses JSON instead:
gh-config --json config show
Uses custom path of config.yaml instead of default:
gh-config --path /path/to/config.yaml config show
Gets an authentication for github.com:
gh-config authn get github.com
Outputs only the OAuth token instead:
gh-config authn get --token-only github.com