look for patreon creds in ~ instead of .
Signed-off-by: Xe Iaso <me@christine.website>
This commit is contained in:
parent
0e22f4c224
commit
e2b9f384bf
|
@ -1619,6 +1619,7 @@ name = "patreon"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"dirs",
|
||||||
"envy",
|
"envy",
|
||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
@ -3110,6 +3111,7 @@ dependencies = [
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
"comrak",
|
"comrak",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
|
"dirs",
|
||||||
"envy",
|
"envy",
|
||||||
"estimated_read_time",
|
"estimated_read_time",
|
||||||
"eyre",
|
"eyre",
|
||||||
|
|
|
@ -16,6 +16,7 @@ color-eyre = "0.6"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
comrak = "0.12.1"
|
comrak = "0.12.1"
|
||||||
derive_more = "0.99"
|
derive_more = "0.99"
|
||||||
|
dirs = "4"
|
||||||
envy = "0.4"
|
envy = "0.4"
|
||||||
estimated_read_time = "1"
|
estimated_read_time = "1"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
|
|
|
@ -8,6 +8,7 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = { version = "0.4", features = ["serde"] }
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
|
dirs = "4"
|
||||||
reqwest = { version = "0.11", features = ["json"] }
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
|
|
@ -125,16 +125,15 @@ pub struct Links {
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
pub fn new() -> Result<Self> {
|
pub fn new() -> Result<Self> {
|
||||||
let mut creds = Credentials::default();
|
let mut p = dirs::home_dir().unwrap_or(".".into());
|
||||||
|
p.push(".patreon.json");
|
||||||
let p = Path::new(".patreon.json");
|
|
||||||
let config = fs::read_to_string(p)?;
|
let config = fs::read_to_string(p)?;
|
||||||
creds = serde_json::from_str(&config)?;
|
let creds = serde_json::from_str(&config)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
cli: reqwest::Client::new(),
|
cli: reqwest::Client::new(),
|
||||||
base_url: "https://api.patreon.com".into(),
|
base_url: "https://api.patreon.com".into(),
|
||||||
creds: creds,
|
creds,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use chrono::prelude::*;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{
|
use std::{
|
||||||
fs,
|
fs,
|
||||||
path::{Path, PathBuf},
|
path::PathBuf,
|
||||||
};
|
};
|
||||||
use tracing::{error, instrument};
|
use tracing::{error, instrument};
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@ pub struct Config {
|
||||||
|
|
||||||
#[instrument]
|
#[instrument]
|
||||||
async fn patrons() -> Result<Option<patreon::Users>> {
|
async fn patrons() -> Result<Option<patreon::Users>> {
|
||||||
let p = Path::new(".patreon.json");
|
let mut p = dirs::home_dir().unwrap_or(".".into());
|
||||||
|
p.push(".patreon.json");
|
||||||
if !p.exists() {
|
if !p.exists() {
|
||||||
info!("{:?} does not exist", p);
|
info!("{:?} does not exist", p);
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
|
|
Loading…
Reference in New Issue