rust #1
2 changed files with 21 additions and 5 deletions
7
config.toml
Normal file
7
config.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Default configuration for jamdl
|
||||||
|
# Please edit these values to match your setup.
|
||||||
|
|
||||||
|
nas_host = "localhost"
|
||||||
|
nas_user = "your_ssh_user"
|
||||||
|
nas_path = "/path/on/nas"
|
||||||
|
cookies_file = "/path/to/your/apple-music-cookies-file.txt"
|
||||||
19
src/main.rs
19
src/main.rs
|
|
@ -2,7 +2,7 @@ use anyhow::{Context, Result};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
|
|
||||||
|
|
@ -25,15 +25,24 @@ struct Args {
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
let config_path = dirs::config_dir()
|
let config_dir = dirs::config_dir()
|
||||||
.context("Could not find config directory")?
|
.context("Could not find config directory")?
|
||||||
.join("jamdl/config.toml");
|
.join("jamdl");
|
||||||
|
let config_path = config_dir.join("config.toml");
|
||||||
|
|
||||||
if !config_path.exists() {
|
if !config_path.exists() {
|
||||||
anyhow::bail!(
|
println!("[INFO] No config file found, creating a default one...");
|
||||||
"Config file not found. Please create it at: {}",
|
fs::create_dir_all(&config_dir).context("Failed to create config directory")?;
|
||||||
|
|
||||||
|
let default_config = include_str!("../config.toml");
|
||||||
|
fs::write(&config_path, default_config).context("Failed to write default config file")?;
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"[INFO] A default config file was created at: {}",
|
||||||
config_path.display()
|
config_path.display()
|
||||||
);
|
);
|
||||||
|
println!("[INFO] Please edit this file with your settings and re-run the command.");
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let settings = config::Config::builder()
|
let settings = config::Config::builder()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue