9 releases

0.4.1 Sep 29, 2024
0.4.0 May 25, 2024
0.3.2 Mar 17, 2024
0.3.1 Dec 29, 2023
0.1.1 Jul 23, 2022

#268 in Configuration

Download history 9/week @ 2024-07-23 6/week @ 2024-07-30 19/week @ 2024-08-06 8/week @ 2024-08-13 2/week @ 2024-08-27 29/week @ 2024-09-03 10/week @ 2024-09-10 1/week @ 2024-09-17 202/week @ 2024-09-24 53/week @ 2024-10-01 13/week @ 2024-10-08 22/week @ 2024-10-15 14/week @ 2024-10-22 15/week @ 2024-10-29 11/week @ 2024-11-05

65 downloads per month
Used in 2 crates

MIT license

23KB
433 lines

gh-config-rs

Rust crates.io docs

Loads config and hosts for gh CLI in Rust.

Getting started

[dependencies]
gh-config = "0.4.0"

Usage

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(())
}

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:

cargo install gh-config --features=cli

Usages

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

Dependencies

~2–47MB
~697K SLoC