Skip to main content

nixpkgs_track/
auth.rs

1use std::process::Command;
2
3use crate::cli::Cli;
4
5pub fn get_github_token(args: &Cli) -> Option<String> {
6	args.token.clone().or_else(|| {
7		Command::new("gh")
8			.args(["auth", "token"])
9			.output()
10			.ok()
11			.filter(|output| output.status.success())
12			.and_then(|output| String::from_utf8(output.stdout).ok())
13			.map(|s| s.trim().to_string())
14	})
15}