rust #1

Merged
chaos merged 8 commits from rust into main 2025-08-17 19:41:08 +01:00
2 changed files with 21 additions and 5 deletions
Showing only changes of commit d2f0340626 - Show all commits

7
config.toml Normal file
View 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"

View file

@ -2,7 +2,7 @@ use anyhow::{Context, Result};
use clap::Parser;
use serde::Deserialize;
use std::fs;
use std::path::{Path, PathBuf};
use std::path::Path;
use std::process::Command;
use tempfile::TempDir;
@ -25,15 +25,24 @@ struct Args {
fn main() -> Result<()> {
let args = Args::parse();
let config_path = dirs::config_dir()
let config_dir = dirs::config_dir()
.context("Could not find config directory")?
.join("jamdl/config.toml");
.join("jamdl");
let config_path = config_dir.join("config.toml");
if !config_path.exists() {
anyhow::bail!(
"Config file not found. Please create it at: {}",
println!("[INFO] No config file found, creating a default one...");
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()
);
println!("[INFO] Please edit this file with your settings and re-run the command.");
return Ok(());
}
let settings = config::Config::builder()