feat: read token from environment
This commit is contained in:
parent
46ab80a7ac
commit
bacb6b4b9a
|
@ -53,9 +53,13 @@ struct Config {
|
|||
static CONFIG: Lazy<Config> = Lazy::new(Config::from_args);
|
||||
|
||||
static GITHUB_TOKEN: Lazy<OsString> = Lazy::new(|| {
|
||||
use std::env;
|
||||
use std::io::{stdin, BufRead, BufReader};
|
||||
use std::os::unix::prelude::*;
|
||||
|
||||
match env::var_os("PR_TRACKER_GITHUB_TOKEN") {
|
||||
Some(token) => token,
|
||||
None => {
|
||||
let mut bytes = Vec::with_capacity(41);
|
||||
if let Err(e) = BufReader::new(stdin()).read_until(b'\n', &mut bytes) {
|
||||
eprintln!("pr-tracker: read: {}", e);
|
||||
|
@ -65,6 +69,8 @@ static GITHUB_TOKEN: Lazy<OsString> = Lazy::new(|| {
|
|||
bytes.pop();
|
||||
}
|
||||
OsString::from_vec(bytes)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
#[derive(Debug, Default, Template)]
|
||||
|
|
Loading…
Reference in a new issue