feat: module periority

This commit is contained in:
iff 2024-12-08 22:56:43 +01:00
parent 03904775f5
commit c1e575c32a
9 changed files with 27 additions and 18 deletions

View file

@ -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

View file

@ -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

4
Cargo.lock generated
View file

@ -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",

View file

@ -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"],
]

View file

@ -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() {

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -17,10 +17,12 @@
There are 2 types of modules:
- **Standard module**: Will always run to retrieve suggestions
- Naming convention: `_pay-respects-module-<your module name>`
- Naming convention: `_pay-respects-module-<priority>-<your module name>`
- **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-<your module name>`
- **CAUTION**: Will immediately return if a suggestion is obtained
- Naming convention: `_pay-respects-fallback-<priority>-<your module name>`
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: