Skip to content
This repository was archived by the owner on Sep 1, 2023. It is now read-only.

Commit 202e4d7

Browse files
committed
feat: allow the token to be overriden by DISCLOUD_TOKEN env variable
1 parent df0c237 commit 202e4d7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/auth.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ pub fn login(token: String) -> std::io::Result<()> {
88
}
99
#[tracing::instrument]
1010
pub fn get_token() -> std::io::Result<String> {
11-
let token_file = crate::config_dir::get_path(".discloud_token").unwrap();
12-
std::fs::read_to_string(token_file)
11+
if let Ok(token) = std::env::var("DISCLOUD_TOKEN") {
12+
Ok(token)
13+
} else {
14+
let token_file = crate::config_dir::get_path(".discloud_token").unwrap();
15+
std::fs::read_to_string(token_file)
16+
}
1317
}
1418
#[tracing::instrument]
1519
pub fn validate_token() -> bool {

0 commit comments

Comments
 (0)