loading environmen variable to config added
This commit is contained in:
64
src/main.rs
64
src/main.rs
@ -1,3 +1,63 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use dotenv::dotenv;
|
||||
use std::collections::HashMap;
|
||||
|
||||
struct ListenBrainz {
|
||||
discovery: String,
|
||||
user: String,
|
||||
}
|
||||
|
||||
pub struct Config {
|
||||
listen_brainz: ListenBrainz,
|
||||
url: String,
|
||||
sleep: i32,
|
||||
playlist_dir: String,
|
||||
persist: bool,
|
||||
system: String,
|
||||
playlist_name: String,
|
||||
}
|
||||
|
||||
struct Credentials {
|
||||
api_key: String,
|
||||
user: String,
|
||||
password: String,
|
||||
headers: HashMap<String, String>,
|
||||
token: String,
|
||||
salt: String,
|
||||
}
|
||||
|
||||
struct Song {
|
||||
title: String,
|
||||
artist: String,
|
||||
album: String,
|
||||
}
|
||||
|
||||
struct Track {
|
||||
album: String,
|
||||
artist: String,
|
||||
title: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
dotenv().ok();
|
||||
// let mailcoach_api_token = std::env::var("MAILCOACH_API_TOKEN").expect("MAILCOACH_API_TOKEN must be set.");
|
||||
let cfg = construct_data();
|
||||
let tracks: Option<Vec<Track>> = None;
|
||||
}
|
||||
|
||||
fn construct_data() -> Config {
|
||||
let lsb = ListenBrainz {
|
||||
discovery: std::env::var("LISTENBRAINZ_DISCOVERY")
|
||||
.expect("LISTENBRAINZ_DISCOVERY must be set."),
|
||||
user: std::env::var("LISTENBRAINZ_USER").expect("LISTENBRAINZ_USER msut be set"),
|
||||
};
|
||||
let config = Config {
|
||||
listen_brainz: lsb,
|
||||
url: std::env::var("SYSTEM_USERNAME").expect("SYSTEM_USERNAME must be set"),
|
||||
sleep: 1,
|
||||
playlist_dir: std::env::var("PLAYLIST_DIR").expect("PLAYLIST_DIR must be set"),
|
||||
persist: true,
|
||||
system: std::env::var("NV_WEEKLY").expect("NV_WEEKLY must be set"),
|
||||
playlist_name: "".to_string(),
|
||||
};
|
||||
return config;
|
||||
}
|
||||
|
Reference in New Issue
Block a user