Update yabridgectl for clap 4.x

This work has been sitting unfinished for ages. The original plan was to
also move it to CLAP's derive macros at the same time, but that makes
some of the path management more difficult.
This commit is contained in:
Robbert van der Helm
2023-12-10 17:10:08 +01:00
parent b9ad1731b9
commit bbec4f3163
5 changed files with 368 additions and 429 deletions
+17 -5
View File
@@ -17,6 +17,7 @@
//! Handlers for the subcommands, just to keep `main.rs` clean.
use anyhow::{Context, Result};
use clap::ValueEnum;
use colored::Colorize;
use std::collections::{HashMap, HashSet};
use std::fs;
@@ -215,13 +216,23 @@ pub fn show_status(config: &Config) -> Result<()> {
}
/// Options passed to `yabridgectl set`, see `main()` for the definitions of these options.
pub struct SetOptions<'a> {
pub struct SetOptions {
pub path: Option<PathBuf>,
pub path_auto: bool,
pub vst2_location: Option<&'a str>,
pub vst2_location: Option<Vst2Location>,
pub no_verify: Option<bool>,
}
/// The location bridged VST2 plugins are set up in.
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum Vst2Location {
/// Sets bridged VST2 plugins up in '~/.vst/yabridge', the default option.
Centralized,
/// Places the yabridge '.so' file alongside the plugin's '.dll' file in the plugin's directory,
/// exists only for legacy purposes.
Inline,
}
/// Change configuration settings. The actual options are defined in the clap [app](clap::App).
pub fn set_settings(config: &mut Config, options: &SetOptions) -> Result<()> {
if let Some(path) = &options.path {
@@ -233,9 +244,10 @@ pub fn set_settings(config: &mut Config, options: &SetOptions) -> Result<()> {
}
match options.vst2_location {
Some("centralized") => config.vst2_location = Vst2InstallationLocation::Centralized,
Some("inline") => config.vst2_location = Vst2InstallationLocation::Inline,
Some(s) => unimplemented!("Unexpected installation method '{}'", s),
Some(Vst2Location::Centralized) => {
config.vst2_location = Vst2InstallationLocation::Centralized
}
Some(Vst2Location::Inline) => config.vst2_location = Vst2InstallationLocation::Inline,
None => (),
}