#cli #protocols #result #git

bin+lib gh-config

Loads config and hosts for gh CLI

6 releases

0.3.1 Dec 29, 2023
0.3.0 Sep 26, 2023
0.2.2 Sep 6, 2023
0.2.1 Aug 28, 2022
0.1.1 Jul 23, 2022

#255 in Configuration

Download history 25/week @ 2023-10-30 23/week @ 2023-11-06 15/week @ 2023-11-13 63/week @ 2023-11-20 40/week @ 2023-11-27 16/week @ 2023-12-04 39/week @ 2023-12-11 27/week @ 2023-12-18 110/week @ 2023-12-25 26/week @ 2024-01-01 26/week @ 2024-01-08 27/week @ 2024-01-15 10/week @ 2024-01-22 29/week @ 2024-01-29 44/week @ 2024-02-05 101/week @ 2024-02-12

188 downloads per month
Used in 2 crates

MIT license

21KB
399 lines

gh-config-rs

Rust crates.io docs

Loads config and hosts for gh CLI in Rust.

Getting started

[dependencies]
gh-config = "0.3"

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–56MB
~849K SLoC