feat: create default config on first run
Co-authored-by: aider (gemini/gemini-2.5-pro-preview-05-06) <aider@aider.chat>
This commit is contained in:
parent
c740e0df0e
commit
d2f0340626
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 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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue