fix auto prompt

This commit is contained in:
Alexander Mohr 2025-04-21 17:48:47 +02:00
parent a655658493
commit 3e34d809be
4 changed files with 12 additions and 27 deletions

View file

@ -42,6 +42,7 @@ layerrule = blur, worf
## Dropped arguments ## Dropped arguments
* `mode`, use show * `mode`, use show
* `dmenu`, use show
* `D`, arguments are the same as config in worf, no need to have this flag. * `D`, arguments are the same as config in worf, no need to have this flag.
### Dropped configuration options ### Dropped configuration options

View file

@ -129,10 +129,6 @@ pub struct Config {
#[clap(short = 'c', long = "conf")] #[clap(short = 'c', long = "conf")]
pub config: Option<String>, pub config: Option<String>,
/// Runs in dmenu mode
#[clap(short = 'd', long = "dmenu")]
pub dmenu: Option<bool>,
/// Prints the version and then exits /// Prints the version and then exits
#[clap(short = 'v', long = "version")] #[clap(short = 'v', long = "version")]
pub version: Option<bool>, pub version: Option<bool>,
@ -338,7 +334,6 @@ impl Default for Config {
Config { Config {
fork: None, fork: None,
config: None, config: None,
dmenu: None,
version: None, version: None,
style: default_style(), style: default_style(),
show: None, show: None,
@ -705,7 +700,9 @@ pub fn load_config(args_opt: Option<Config>) -> Result<Config, ConfigurationErro
Mode::Run => merge_result.prompt = Some("run".to_owned()), Mode::Run => merge_result.prompt = Some("run".to_owned()),
Mode::Drun => merge_result.prompt = Some("drun".to_owned()), Mode::Drun => merge_result.prompt = Some("drun".to_owned()),
Mode::Dmenu => merge_result.prompt = Some("dmenu".to_owned()), Mode::Dmenu => merge_result.prompt = Some("dmenu".to_owned()),
_ => {} Mode::Math => merge_result.prompt = Some("math".to_owned()),
Mode::File => merge_result.prompt = Some("file".to_owned()),
Mode::Auto => merge_result.prompt = Some("auto".to_owned()),
}, },
} }
} }

View file

@ -392,13 +392,10 @@ impl ItemProvider<AutoRunType> for AutoItemProvider {
/// # Errors /// # Errors
/// ///
/// Will return `Err` if it was not able to spawn the process /// Will return `Err` if it was not able to spawn the process
pub fn d_run(config: &mut Config) -> anyhow::Result<()> { pub fn d_run(config: &Config) -> anyhow::Result<()> {
let provider = DRunProvider::new("".to_owned()); let provider = DRunProvider::new("".to_owned());
let cache_path = provider.cache_path.clone(); let cache_path = provider.cache_path.clone();
let mut cache = provider.cache.clone(); let mut cache = provider.cache.clone();
if config.prompt.is_none() {
config.prompt = Some("drun".to_owned());
}
// todo ues a arc instead of cloning the config // todo ues a arc instead of cloning the config
let selection_result = gui::show(config.clone(), provider); let selection_result = gui::show(config.clone(), provider);
@ -414,15 +411,11 @@ pub fn d_run(config: &mut Config) -> anyhow::Result<()> {
Ok(()) Ok(())
} }
pub fn auto(config: &mut Config) -> anyhow::Result<()> { pub fn auto(config: &Config) -> anyhow::Result<()> {
let provider = AutoItemProvider::new(); let provider = AutoItemProvider::new();
let cache_path = provider.drun_provider.cache_path.clone(); let cache_path = provider.drun_provider.cache_path.clone();
let mut cache = provider.drun_provider.cache.clone(); let mut cache = provider.drun_provider.cache.clone();
if config.prompt.is_none() {
config.prompt = Some("auto".to_owned());
}
// todo ues a arc instead of cloning the config // todo ues a arc instead of cloning the config
let selection_result = gui::show(config.clone(), provider); let selection_result = gui::show(config.clone(), provider);
@ -453,11 +446,8 @@ pub fn auto(config: &mut Config) -> anyhow::Result<()> {
Ok(()) Ok(())
} }
pub fn file(config: &mut Config) -> Result<(), String> { pub fn file(config: &Config) -> Result<(), String> {
let provider = FileItemProvider::new("".to_owned()); let provider = FileItemProvider::new("".to_owned());
if config.prompt.is_none() {
config.prompt = Some("file".to_owned());
}
// todo ues a arc instead of cloning the config // todo ues a arc instead of cloning the config
let selection_result = gui::show(config.clone(), provider); let selection_result = gui::show(config.clone(), provider);
@ -475,11 +465,8 @@ pub fn file(config: &mut Config) -> Result<(), String> {
Ok(()) Ok(())
} }
pub fn math(config: &mut Config) -> Result<(), String> { pub fn math(config: &Config) -> Result<(), String> {
let provider = MathProvider::new("".to_owned()); let provider = MathProvider::new("".to_owned());
if config.prompt.is_none() {
config.prompt = Some("math".to_owned());
}
// todo ues a arc instead of cloning the config // todo ues a arc instead of cloning the config
let selection_result = gui::show(config.clone(), provider); let selection_result = gui::show(config.clone(), provider);

View file

@ -21,19 +21,19 @@ fn main() -> anyhow::Result<()> {
todo!("run not implemented") todo!("run not implemented")
} }
Mode::Drun => { Mode::Drun => {
mode::d_run(&mut config)?; mode::d_run(&config)?;
} }
Mode::Dmenu => { Mode::Dmenu => {
todo!("dmenu not implemented") todo!("dmenu not implemented")
} }
Mode::File => { Mode::File => {
mode::file(&mut config).map_err(|e| anyhow!(e))?; mode::file(&config).map_err(|e| anyhow!(e))?;
} }
Mode::Math => { Mode::Math => {
mode::math(&mut config).map_err(|e| anyhow!(e))?; mode::math(&config).map_err(|e| anyhow!(e))?;
} }
Mode::Auto => { Mode::Auto => {
mode::auto(&mut config)?; mode::auto(&config)?;
} }
} }