feat(qbzd): setup subcommand placeholder + config save helper
CLI now shows all 5 subcommands: login, status, token, setup, help. Setup placeholder ready for TUI wizard implementation (ratatui). Config save helper for persisting changes to qbzd.toml. cc
This commit is contained in:
2 files changed
+31
No files matched your search
@@ -257,3 +257,21 @@ pub fn generate_token() -> String {
|
|||||||
.as_nanos();
|
.as_nanos();
|
||||||
format!("{:032x}", seed)
|
format!("{:032x}", seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Save config to the default config path (creates dir if needed).
|
||||||
|
pub fn save_default_config(config: &DaemonConfig) -> Result<(), String> {
|
||||||
|
let config_dir = dirs::config_dir()
|
||||||
|
.ok_or("Could not determine config directory")?
|
||||||
|
.join("qbz");
|
||||||
|
std::fs::create_dir_all(&config_dir)
|
||||||
|
.map_err(|e| format!("Failed to create config dir: {}", e))?;
|
||||||
|
|
||||||
|
let path = config_dir.join("qbzd.toml");
|
||||||
|
let content = toml::to_string_pretty(config)
|
||||||
|
.map_err(|e| format!("Failed to serialize config: {}", e))?;
|
||||||
|
std::fs::write(&path, content)
|
||||||
|
.map_err(|e| format!("Failed to write config: {}", e))?;
|
||||||
|
|
||||||
|
log::info!("[qbzd] Config saved to {}", path.display());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -57,6 +57,12 @@ enum Commands {
|
|||||||
Status,
|
Status,
|
||||||
/// Show or regenerate API token
|
/// Show or regenerate API token
|
||||||
Token,
|
Token,
|
||||||
|
/// Interactive setup wizard (audio, playback, integrations)
|
||||||
|
Setup {
|
||||||
|
/// Run only a specific section (audio, playback, cache, integrations, qconnect)
|
||||||
|
#[arg(long)]
|
||||||
|
section: Option<String>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@@ -124,6 +130,13 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some(Commands::Setup { section }) => {
|
||||||
|
eprintln!("TUI setup wizard not yet implemented.");
|
||||||
|
if let Some(s) = section {
|
||||||
|
eprintln!("Requested section: {}", s);
|
||||||
|
}
|
||||||
|
eprintln!("Use the HTTP API or qbzd.toml to configure for now.");
|
||||||
|
}
|
||||||
Some(Commands::Token) => {
|
Some(Commands::Token) => {
|
||||||
if cfg.server.token == "auto" {
|
if cfg.server.token == "auto" {
|
||||||
let token = config::generate_token();
|
let token = config::generate_token();
|
||||||
|
|||||||
Reference in new issue
Block a user