33 lines
991 B
Rust
33 lines
991 B
Rust
use clap::Parser;
|
|
use std::path::PathBuf;
|
|
use crate::*;
|
|
|
|
#[derive(Parser)]
|
|
#[command(name = "audio_engine")]
|
|
#[command(about = "FCB1010 Looper Pedal Audio Engine")]
|
|
pub struct Args {
|
|
/// Path to Unix socket or named pipe name
|
|
#[arg(short = 's', long = "socket", env = "SOCKET", default_value = "/tmp/fcb_looper.sock")]
|
|
pub socket: String,
|
|
|
|
/// Path to configuration file
|
|
#[arg(short = 'c', long = "config-file", env = "CONFIG_FILE", default_value = default_config_path())]
|
|
pub config_file: PathBuf,
|
|
}
|
|
|
|
impl Args {
|
|
pub fn new() -> Result<Self> {
|
|
let res = Self::try_parse();
|
|
if let Err(res) = &res {
|
|
log::error!("{res}");
|
|
}
|
|
res.map_err(|_| LooperError::ArgsParse(std::panic::Location::caller()))
|
|
}
|
|
}
|
|
|
|
fn default_config_path() -> String {
|
|
let mut path = dirs::home_dir().unwrap_or_else(|| PathBuf::from("."));
|
|
path.push(".fcb_looper");
|
|
path.push("state.json");
|
|
path.to_string_lossy().to_string()
|
|
} |