From 40226a2bbdec365e23ad519538fb83d058df92b0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 2 Nov 2021 13:41:03 -0700 Subject: [PATCH] refactor(wm): update cmds & keep compat w/ aliases This commit updates a number of komorebic subcommand names while maintaining their old names as aliases in order to preserve backwards compatibility. Resize becomes ResizeEdge, to complement ResizeAxis, and all of the commands for saving and loading BSP resize adjustments (QuickSave, QuickLoad, Save, Load) are now post-fixed with "Resize" in order to make it clear that these commands are not related to custom layout saving and loading. --- komorebic.lib.sample.ahk | 16 ++++++++-------- komorebic/src/main.rs | 29 +++++++++++++++++------------ 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/komorebic.lib.sample.ahk b/komorebic.lib.sample.ahk index 948ff544..e88e1633 100644 --- a/komorebic.lib.sample.ahk +++ b/komorebic.lib.sample.ahk @@ -28,20 +28,20 @@ Log() { Run, komorebic.exe log, , Hide } -QuickSave() { - Run, komorebic.exe quick-save, , Hide +QuickSaveResize() { + Run, komorebic.exe quick-save-resize, , Hide } -QuickLoad() { - Run, komorebic.exe quick-load, , Hide +QuickLoadResize() { + Run, komorebic.exe quick-load-resize, , Hide } -Save(path) { - Run, komorebic.exe save %path%, , Hide +SaveResize(path) { + Run, komorebic.exe save-resize %path%, , Hide } -Load(path) { - Run, komorebic.exe load %path%, , Hide +LoadResize(path) { + Run, komorebic.exe load-resize %path%, , Hide } Focus(operation_direction) { diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 117ef5fc..7ab2a6c0 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -306,13 +306,13 @@ struct Start { } #[derive(Parser, AhkFunction)] -struct Save { +struct SaveResize { /// File to which the resize layout dimensions should be saved path: String, } #[derive(Parser, AhkFunction)] -struct Load { +struct LoadResize { /// File from which the resize layout dimensions should be loaded path: String, } @@ -362,15 +362,19 @@ enum SubCommand { /// Tail komorebi.exe's process logs (cancel with Ctrl-C) Log, /// Quicksave the current resize layout dimensions - QuickSave, + #[clap(alias = "quick-save")] + QuickSaveResize, /// Load the last quicksaved resize layout dimensions - QuickLoad, + #[clap(alias = "quick-load")] + QuickLoadResize, /// Save the current resize layout dimensions to a file #[clap(setting = AppSettings::ArgRequiredElseHelp)] - Save(Save), + #[clap(alias = "save")] + SaveResize(SaveResize), /// Load the resize layout dimensions from a file #[clap(setting = AppSettings::ArgRequiredElseHelp)] - Load(Load), + #[clap(alias = "load")] + LoadResize(LoadResize), /// Change focus to the window in the specified direction #[clap(setting = AppSettings::ArgRequiredElseHelp)] Focus(Focus), @@ -388,7 +392,8 @@ enum SubCommand { Stack(Stack), /// Resize the focused window in the specified direction #[clap(setting = AppSettings::ArgRequiredElseHelp)] - Resize(Resize), + #[clap(alias = "resize")] + ResizeEdge(Resize), /// Resize the focused window along the specified axis #[clap(setting = AppSettings::ArgRequiredElseHelp)] ResizeAxis(ResizeAxis), @@ -878,7 +883,7 @@ fn main() -> Result<()> { restore_window(HWND(hwnd)); } } - SubCommand::Resize(resize) => { + SubCommand::ResizeEdge(resize) => { send_message( &*SocketMessage::ResizeWindowEdge(resize.edge, resize.sizing).as_bytes()?, )?; @@ -917,16 +922,16 @@ fn main() -> Result<()> { SubCommand::Unmanage => { send_message(&*SocketMessage::UnmanageFocusedWindow.as_bytes()?)?; } - SubCommand::QuickSave => { + SubCommand::QuickSaveResize => { send_message(&*SocketMessage::QuickSave.as_bytes()?)?; } - SubCommand::QuickLoad => { + SubCommand::QuickLoadResize => { send_message(&*SocketMessage::QuickLoad.as_bytes()?)?; } - SubCommand::Save(arg) => { + SubCommand::SaveResize(arg) => { send_message(&*SocketMessage::Save(resolve_windows_path(&arg.path)?).as_bytes()?)?; } - SubCommand::Load(arg) => { + SubCommand::LoadResize(arg) => { send_message(&*SocketMessage::Load(resolve_windows_path(&arg.path)?).as_bytes()?)?; } SubCommand::Subscribe(arg) => {