mod debug;
mod dispatch;
mod gui;
mod init;
mod shared;
mod simple;
use std::fmt::Debug;
use clap::{Args, Parser, Subcommand};
pub use debug::DebugCommand;
#[derive(Parser, Debug, Clone)]
#[command(
author,
version,
about,
long_about = "A CLI/GUI that allows switching between windows in Hyprland\nvisit https://github.com/H3rmt/hyprswitch/wiki/Examples to see Example configs"
)]
pub struct App {
#[clap(flatten)]
pub global_opts: GlobalOpts,
#[clap(subcommand)]
pub command: Command,
}
#[derive(Args, Debug, Clone)]
pub struct GlobalOpts {
#[arg(short = 'd', long, global = true)]
pub dry_run: bool,
#[arg(short = 'v', action = clap::ArgAction::Count, global = true)]
pub verbose: u8,
#[arg(short = 'q', long, global = true)]
pub quiet: bool,
}
#[derive(Subcommand, Debug, Clone)]
pub enum Command {
#[cfg(feature = "config")]
Generate {
#[arg(long, short = 'w')]
config_file: Option<std::path::PathBuf>,
#[arg(long)]
exe: Option<std::path::PathBuf>,
},
Init {
#[clap(flatten)]
init_opts: init::InitOpts,
},
#[clap(hide = true)]
Dispatch {
#[clap(flatten)]
dispatch_config: dispatch::DispatchConf,
},
#[clap(hide = true)]
Gui {
#[clap(flatten)]
submap_conf: gui::SubmapConf,
#[arg(long, value_parser = clap::value_parser!(shared::InputReverseKey), default_value = "mod=shift")]
reverse_key: shared::InputReverseKey,
#[clap(flatten)]
gui_conf: gui::GuiConf,
#[clap(flatten)]
simple_config: simple::SimpleConf,
},
Simple {
#[clap(flatten)]
dispatch_config: dispatch::DispatchConf,
#[clap(flatten)]
simple_conf: simple::SimpleConf,
},
#[clap(hide = true)]
Close {
#[arg(long)]
kill: bool,
},
Debug {
#[clap(subcommand)]
command: DebugCommand,
},
}
pub fn check_invalid_inputs(e: &clap::Error) -> bool {
e.to_string()
.starts_with("A CLI/GUI that allows switching between windows in Hyprland")
|| e.to_string().starts_with("Initialize and start the Daemon")
|| e.to_string()
.starts_with("Switch without using the GUI / Daemon (switches directly)")
|| e.to_string().starts_with(
"Debug command to debug finding icons for the GUI, doesn't interact with the Daemon",
)
}