https://github.com/siketyan/gh-config-rs
🐙 Loads config and hosts from gh CLI in Rust.
https://github.com/siketyan/gh-config-rs
cli config github rust-crate
Last synced: over 1 year ago
JSON representation
🐙 Loads config and hosts from gh CLI in Rust.
- Host: GitHub
- URL: https://github.com/siketyan/gh-config-rs
- Owner: siketyan
- License: mit
- Created: 2022-07-23T13:15:35.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-11T01:50:12.000Z (over 1 year ago)
- Last Synced: 2025-03-15T21:31:02.269Z (over 1 year ago)
- Topics: cli, config, github, rust-crate
- Language: Rust
- Homepage: https://crates.io/crates/gh-config
- Size: 425 KB
- Stars: 5
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gh-config-rs
[](https://github.com/siketyan/gh-config-rs/actions/workflows/rust.yml)
[](https://crates.io/crates/gh-config)
[](https://docs.rs/gh-config/)
Loads config and hosts for gh CLI in Rust.
## Getting started
```toml
[dependencies]
gh-config = "0.5.1"
```
## Usage
```rust
use std::error::Error;
use gh_config::*;
fn main() -> Result<(), Box> {
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(())
}
```
## CLI
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
```
### Usages
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
```