Add config and service subcommands
config subcommand — show, path, edit ($EDITOR), and a non-interactive set that takes --prefix / --compat-dir / --gameid. Lets users retarget the Wine prefix without hand-editing TOML. service subcommand — install / uninstall / status for a systemd --user unit that autostarts the tray. install writes ~/.config/systemd/user/ battlenet-manager.service with ExecStart pointing at the current binary, then daemon-reloads and enable --now's the unit. uninstall tears it back down. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+64
@@ -2,10 +2,12 @@ mod config;
|
||||
mod diagnose;
|
||||
mod launcher;
|
||||
mod proton;
|
||||
mod service;
|
||||
mod tray;
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::{Parser, Subcommand};
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Battle.net launcher manager for Linux via umu/Proton-GE.
|
||||
///
|
||||
@@ -46,6 +48,52 @@ enum Commands {
|
||||
#[arg(long)]
|
||||
list: bool,
|
||||
},
|
||||
|
||||
/// Show or modify configuration
|
||||
Config {
|
||||
#[command(subcommand)]
|
||||
action: ConfigAction,
|
||||
},
|
||||
|
||||
/// Manage the systemd --user service that autostarts the tray
|
||||
Service {
|
||||
#[command(subcommand)]
|
||||
action: ServiceAction,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum ConfigAction {
|
||||
/// Print the config file path and current values
|
||||
Show,
|
||||
/// Print just the config file path
|
||||
Path,
|
||||
/// Open the config file in $EDITOR
|
||||
Edit,
|
||||
/// Update one or more fields non-interactively
|
||||
Set {
|
||||
/// Wine prefix directory
|
||||
#[arg(long, value_name = "PATH")]
|
||||
prefix: Option<PathBuf>,
|
||||
|
||||
/// GE-Proton install directory
|
||||
#[arg(long, value_name = "PATH")]
|
||||
compat_dir: Option<PathBuf>,
|
||||
|
||||
/// umu GAMEID (used for protonfixes lookup)
|
||||
#[arg(long, value_name = "ID")]
|
||||
gameid: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum ServiceAction {
|
||||
/// Write the unit, daemon-reload, and enable+start the service
|
||||
Install,
|
||||
/// Stop, disable, and remove the unit file
|
||||
Uninstall,
|
||||
/// Show `systemctl --user status` for the service
|
||||
Status,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
@@ -60,6 +108,22 @@ fn main() -> Result<()> {
|
||||
Commands::UpdateProton { latest, version, list } => {
|
||||
proton::run(&config, latest, version, list)?;
|
||||
}
|
||||
Commands::Config { action } => match action {
|
||||
ConfigAction::Show => config.show()?,
|
||||
ConfigAction::Path => {
|
||||
println!("{}", config::Config::config_path()?.display());
|
||||
}
|
||||
ConfigAction::Edit => config::Config::edit()?,
|
||||
ConfigAction::Set { prefix, compat_dir, gameid } => {
|
||||
let mut c = config;
|
||||
c.set_fields(prefix, compat_dir, gameid)?;
|
||||
}
|
||||
},
|
||||
Commands::Service { action } => match action {
|
||||
ServiceAction::Install => service::install()?,
|
||||
ServiceAction::Uninstall => service::uninstall()?,
|
||||
ServiceAction::Status => service::status()?,
|
||||
},
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user