Crate gh_config

source ·
Expand description

gh-config

Loads config and hosts for gh CLI.

Getting started

[dependencies]
gh-config = "0.1"

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: {}", hosts.retrieve_token(GITHUB_COM)?.unwrap()),
        _ => eprintln!("Token not found."),
    }

    Ok(())
}

Structs

  • Config representation for gh CLI.
  • Host config representation for gh CLI.
  • Mapped host configs by their hostname.

Enums

  • An error occurred in this crate.
  • What protocol to use when performing git operations.
  • When to interactively prompt.

Constants

Functions

  • Finds the default config directory effected by the environment.
  • Loads a file in the config directory as T type.