Skip to content

Commit

Permalink
refactor(komorebic): update clap, add cli docs
Browse files Browse the repository at this point in the history
The latest clap beta introduced a lot of breaking changes for komorebic,
so I decided it was a good time to refactor a little and add
documentation to all of the cli commands.

The primary change for komorebic is that subcommands now only take
structs as arguments, so every enum must be wrapped in a struct. Some
macros have been introduced to ease this.

Using on|off alongside enable|disable for BooleanState arguments has
been deprecated, going forward only enable|disable will be supported.

The commands to introduce float rules have been refactored to make use
of ApplicationTarget, and a single command 'float-rule' has been
introduced in the cli.

Finally I took some time to standardise the sample AHK config a little,
primarily making sure that command prompt windows are never shown for
any of the configuration commands.

BREAKING CHANGE: float-exe, float-class, and float-title have been
deprecated in favour of float-rule in komorebic. workspace-tiling now
only accepts enable|disable as valid inputs to the final arg,
deprecating the previously also valid on|off.

re #8
  • Loading branch information
LGUG2Z committed Aug 16, 2021
1 parent 7ede5a2 commit 9c55545
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 219 deletions.
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions README.md
Expand Up @@ -88,9 +88,9 @@ If you have AutoHotKey installed and a `komorebi.ahk` file in your home director
PowerShell prompt to find your home directory), `komorebi` will automatically try to load it when starting.

If you are experiencing behaviour where
[closing a window leaves a blank tile, but minimizing the same window does not](https://github.com/LGUG2Z/komorebi/issues/6),
you have probably enabled a 'close/minimize to tray' option for that application. You can tell _komorebi_ to handle this
application appropriately by identifying it via the executable name or the window class:
[closing a window leaves a blank tile, but minimizing the same window does not](https://github.com/LGUG2Z/komorebi/issues/6)
, you have probably enabled a 'close/minimize to tray' option for that application. You can tell _komorebi_ to handle
this application appropriately by identifying it via the executable name or the window class:

```powershell
komorebic.exe identify-tray-application exe Discord.exe
Expand All @@ -103,6 +103,10 @@ As previously mentioned, this project does not handle anything related to keybin
personally use AutoHotKey to manage my window management shortcuts, and have provided a
sample [komorebi.ahk](komorebi.sample.ahk) AHK script that you can use as a starting point for your own.

You can run `komorebic.exe` to get a full list of the commands that you can use to customise `komorebi` and create
keybindings with. You can run `komorebic.exe <COMMAND> --help` to get a full explanation of the arguments required for
each command.

## Features

- [x] Multi-monitor
Expand Down
3 changes: 2 additions & 1 deletion bindings/build.rs
Expand Up @@ -18,7 +18,8 @@ fn main() {
Windows::Win32::System::Threading::AttachThreadInput,
Windows::Win32::System::Threading::GetCurrentProcessId,
Windows::Win32::UI::KeyboardAndMouseInput::SetFocus,
Windows::Win32::UI::Accessibility::{SetWinEventHook, HWINEVENTHOOK},
Windows::Win32::UI::Accessibility::SetWinEventHook,
Windows::Win32::UI::Accessibility::HWINEVENTHOOK,
// error: `Windows.Win32.UI.WindowsAndMessaging.GWL_EXSTYLE` not found in metadata
Windows::Win32::UI::WindowsAndMessaging::*,
);
Expand Down
2 changes: 1 addition & 1 deletion komorebi-core/Cargo.toml
Expand Up @@ -8,7 +8,7 @@ edition = "2018"
[dependencies]
bindings = { package = "bindings", path = "../bindings" }

clap = "3.0.0-beta.2"
clap = "3.0.0-beta.4"
color-eyre = "0.5"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
5 changes: 2 additions & 3 deletions komorebi-core/src/cycle_direction.rs
@@ -1,12 +1,11 @@
use clap::Clap;
use clap::ArgEnum;
use serde::Deserialize;
use serde::Serialize;
use strum::Display;
use strum::EnumString;

#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString)]
#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ArgEnum)]
#[strum(serialize_all = "snake_case")]
#[derive(Clap)]
pub enum CycleDirection {
Previous,
Next,
Expand Down
8 changes: 3 additions & 5 deletions komorebi-core/src/layout.rs
@@ -1,6 +1,6 @@
use std::num::NonZeroUsize;

use clap::Clap;
use clap::ArgEnum;
use serde::Deserialize;
use serde::Serialize;
use strum::Display;
Expand All @@ -10,18 +10,16 @@ use crate::OperationDirection;
use crate::Rect;
use crate::Sizing;

#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString)]
#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ArgEnum)]
#[strum(serialize_all = "snake_case")]
#[derive(Clap)]
pub enum Layout {
BSP,
Columns,
Rows,
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString)]
#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ArgEnum)]
#[strum(serialize_all = "snake_case")]
#[derive(Clap)]
pub enum LayoutFlip {
Horizontal,
Vertical,
Expand Down
8 changes: 4 additions & 4 deletions komorebi-core/src/lib.rs
@@ -1,6 +1,6 @@
use std::str::FromStr;

use clap::Clap;
use clap::ArgEnum;
use color_eyre::Result;
use serde::Deserialize;
use serde::Serialize;
Expand Down Expand Up @@ -80,16 +80,16 @@ impl FromStr for SocketMessage {
}
}

#[derive(Clone, Debug, Serialize, Deserialize, Display, EnumString)]
#[derive(Clone, Debug, Serialize, Deserialize, Display, EnumString, ArgEnum)]
#[strum(serialize_all = "snake_case")]
pub enum ApplicationIdentifier {
Exe,
Class,
Title,
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString)]
#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ArgEnum)]
#[strum(serialize_all = "snake_case")]
#[derive(Clap)]
pub enum Sizing {
Increase,
Decrease,
Expand Down
5 changes: 2 additions & 3 deletions komorebi-core/src/operation_direction.rs
@@ -1,4 +1,4 @@
use clap::Clap;
use clap::ArgEnum;
use serde::Deserialize;
use serde::Serialize;
use strum::Display;
Expand All @@ -7,9 +7,8 @@ use strum::EnumString;
use crate::Layout;
use crate::LayoutFlip;

#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString)]
#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ArgEnum)]
#[strum(serialize_all = "snake_case")]
#[derive(Clap)]
pub enum OperationDirection {
Left,
Right,
Expand Down

0 comments on commit 9c55545

Please sign in to comment.