From c1e575c32a04de89f18c809f62ac542ec4f4c304 Mon Sep 17 00:00:00 2001 From: iff Date: Sun, 8 Dec 2024 22:56:43 +0100 Subject: [PATCH] feat: module periority --- .github/workflows/build.yaml | 8 ++++---- CHANGELOG.md | 9 +++++++-- Cargo.lock | 4 ++-- core/Cargo.toml | 4 ++-- core/src/shell.rs | 2 ++ install.sh | 2 +- module-request-ai/Cargo.toml | 4 ++-- module-runtime-rules/Cargo.toml | 4 ++-- modules.md | 8 +++++--- 9 files changed, 27 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5e6326e..769a20c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -88,8 +88,8 @@ jobs: run: > 7z a pay-respects-${{ steps.version.outputs.VERSION }}-${{ matrix.target }}.zip ./target/${{ matrix.target }}/release/pay-respects.exe - ./target/${{ matrix.target }}/release/_pay-respects-module-runtime-rules.exe - ./target/${{ matrix.target }}/release/_pay-respects-fallback-request-ai.exe + ./target/${{ matrix.target }}/release/_pay-respects-module-100-runtime-rules.exe + ./target/${{ matrix.target }}/release/_pay-respects-fallback-100-request-ai.exe - name: zipping files (unix) if: runner.os != 'Windows' @@ -97,8 +97,8 @@ jobs: tar -czf pay-respects-${{ steps.version.outputs.VERSION }}-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release pay-respects - _pay-respects-module-runtime-rules - _pay-respects-fallback-request-ai + _pay-respects-module-100-runtime-rules + _pay-respects-fallback-100-request-ai - name: uploading to release uses: ncipollo/release-action@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 493fb04..f0faf54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,11 @@ All notable changes to components of this project since 0.5.14 will be documente The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.6.1] - 2024-12-09 + +### Added + +- Custom priority for modules ### Changed @@ -45,7 +49,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 History start. -[unreleased]: https://github.com/iffse/pay-respects/compare/v0.6.0..HEAD +[unreleased]: https://github.com/iffse/pay-respects/compare/v0.6.1..HEAD +[0.6.1]: https://github.com/iffse/pay-respects/compare/v0.6.0..v0.6.1 [0.6.0]: https://github.com/iffse/pay-respects/compare/v0.5.15..v0.6.0 [0.5.15]: https://github.com/iffse/pay-respects/compare/v0.5.14..v0.5.15 [0.5.14]: https://github.com/iffse/pay-respects/commits/v0.5.14 diff --git a/Cargo.lock b/Cargo.lock index 1a76ae0..09ede24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -481,7 +481,7 @@ dependencies = [ [[package]] name = "pay-respects-module-request-ai" -version = "0.1.1" +version = "0.1.2" dependencies = [ "colored", "curl", @@ -494,7 +494,7 @@ dependencies = [ [[package]] name = "pay-respects-module-runtime-rules" -version = "0.1.1" +version = "0.1.2" dependencies = [ "pay-respects-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex-lite", diff --git a/core/Cargo.toml b/core/Cargo.toml index bfffdb5..c40da8a 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -29,6 +29,6 @@ pay-respects-utils = "0.1.0" [package.metadata.deb] assets = [ ["target/release/pay-respects", "usr/bin/", "755"], - ["target/release/_pay-respects-module-runtime-rules", "usr/bin/", "755"], - ["target/release/_pay-respects-fallback-request-ai", "usr/bin/", "755"], + ["target/release/_pay-respects-module-100-runtime-rules", "usr/bin/", "755"], + ["target/release/_pay-respects-fallback-100-request-ai", "usr/bin/", "755"], ] diff --git a/core/src/shell.rs b/core/src/shell.rs index e76e1c3..131e9b8 100644 --- a/core/src/shell.rs +++ b/core/src/shell.rs @@ -68,6 +68,8 @@ impl Data { executables.push(exe.to_string()); } } + modules.sort_unstable(); + fallbacks.sort_unstable(); if alias.is_some() { let alias = alias.as_ref().unwrap(); for command in alias.keys() { diff --git a/install.sh b/install.sh index 51af090..ce8c3c8 100644 --- a/install.sh +++ b/install.sh @@ -19,7 +19,7 @@ main() { echo "Detected architecture: ${_arch}" local _bin_name="pay-respects" - local _modules="_pay-respects-module-runtime-rules _pay-respects-fallback-request-ai" + local _modules="_pay-respects-module-100-runtime-rules _pay-respects-fallback-100-request-ai" case "${_arch}" in *windows*) _bin_name="${_bin_name}.exe" diff --git a/module-request-ai/Cargo.toml b/module-request-ai/Cargo.toml index ecc6c56..5e5a6fa 100644 --- a/module-request-ai/Cargo.toml +++ b/module-request-ai/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pay-respects-module-request-ai" -version = "0.1.1" +version = "0.1.2" edition = "2021" description = "AI request module for the pay-respects CLI tool" @@ -27,5 +27,5 @@ default = ["libcurl"] libcurl = ["dep:curl"] [[bin]] -name = "_pay-respects-fallback-request-ai" +name = "_pay-respects-fallback-100-request-ai" path = "src/main.rs" diff --git a/module-runtime-rules/Cargo.toml b/module-runtime-rules/Cargo.toml index 4cb3a10..ffb58dd 100644 --- a/module-runtime-rules/Cargo.toml +++ b/module-runtime-rules/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pay-respects-module-runtime-rules" -version = "0.1.1" +version = "0.1.2" edition = "2021" # for crates.io @@ -20,5 +20,5 @@ pay-respects-utils = "0.1.0" # pay-respects-utils = { path = "../utils" } [[bin]] -name = "_pay-respects-module-runtime-rules" +name = "_pay-respects-module-100-runtime-rules" path = "src/main.rs" diff --git a/modules.md b/modules.md index f370a11..2f740d4 100644 --- a/modules.md +++ b/modules.md @@ -17,10 +17,12 @@ There are 2 types of modules: - **Standard module**: Will always run to retrieve suggestions - - Naming convention: `_pay-respects-module-` + - Naming convention: `_pay-respects-module--` - **Fallback module**: Will only be run if no previous suggestion were found - - **CAUTION**: Will immediately return if a suggestion is obtained, and there is no guaranteed the modules are executed in a specific order. - - Naming convention: `_pay-respects-fallback-` + - **CAUTION**: Will immediately return if a suggestion is obtained + - Naming convention: `_pay-respects-fallback--` + +Priority is used to retrieve suggestions in a specific order by an [unstable sort](https://doc.rust-lang.org/std/primitive.slice.html#method.sort_unstable) (although they will always be after compile-time matches). Default modules have a priority of `100`. When running your module, you will get the following environment variables: