refactor(derive-ahk): push up generation logic

This commit pushes as much of the generation logic as possible to the
derive-ahk crate, so that when it is used in komorebic, we only need to
do an as_bytes() call to prepare it for being written to a file.

Besides that, this commit changes the generation command name to
'ahk-library' for clarity, and adds both additional samples and
instructions in the readme file and Scoop post-install hook.
This commit is contained in:
LGUG2Z
2021-08-23 07:49:34 -07:00
parent 2c876701d8
commit a02cd699a0
6 changed files with 238 additions and 17 deletions

View File

@@ -337,7 +337,7 @@ enum SubCommand {
/// Enable or disable focus follows mouse for the operating system
FocusFollowsMouse(FocusFollowsMouse),
/// Generate a library of AutoHotKey helper functions
AhkLib,
AhkLibrary,
}
pub fn send_message(bytes: &[u8]) -> Result<()> {
@@ -354,7 +354,7 @@ fn main() -> Result<()> {
let opts: Opts = Opts::parse();
match opts.subcmd {
SubCommand::AhkLib => {
SubCommand::AhkLibrary => {
let mut library = dirs::home_dir().context("there is no home directory")?;
library.push("komorebic.lib.ahk");
let mut file = OpenOptions::new()
@@ -363,8 +363,7 @@ fn main() -> Result<()> {
.truncate(true)
.open(library.clone())?;
let library_text: String = SubCommand::ahk_functions().join("\n");
file.write_all(library_text.as_bytes())?;
file.write_all(SubCommand::generate_ahk_library().as_bytes())?;
println!(
"\nAHK helper library for komorebic written to {}",