From 373c1d0858f11639caac7c1009128a993e78eec9 Mon Sep 17 00:00:00 2001 From: Matt Joyce Date: Thu, 5 Dec 2024 22:28:38 +1100 Subject: [PATCH] added test pattern --- plugins/template/Examples/README.md | 74 +++++++++++------------ plugins/template/Examples/test_pattern.md | 8 +++ 2 files changed, 42 insertions(+), 40 deletions(-) create mode 100644 plugins/template/Examples/test_pattern.md diff --git a/plugins/template/Examples/README.md b/plugins/template/Examples/README.md index c8c9b08a..e32e0005 100644 --- a/plugins/template/Examples/README.md +++ b/plugins/template/Examples/README.md @@ -93,12 +93,15 @@ config: fabric --addextension ~/.config/fabric/extensions/configs/word-generator.yaml # Run (generate 3 random words) -fabric -p "{{ext:word-generator:generate:3}}" +echo "{{ext:word-generator:generate:3}}" | fabric ``` ## Example 2: Direct Executable (SQLite3) Using a system executable directly. +copy the memories to your home directory + ~/memories.db + ### 1. Configure Create `~/.config/fabric/extensions/configs/memory-query.yaml`: ```yaml @@ -130,50 +133,22 @@ config: fabric --addextension ~/.config/fabric/extensions/configs/memory-query.yaml # Run queries -fabric -p "{{ext:memory-query:all}}" -fabric -p "{{ext:memory-query:byid:123}}" +echo "{{ext:memory-query:all}}" | fabric +echo "{{ext:memory-query:byid:3}}" | fabric ``` -## Example 3: Local Shell Script (Package Tracker) -Running a local system administration script. - -### 1. Position Files -```bash -# Install script -sudo cp track_packages.sh ~/.config/fabric/extensions/bin/ -sudo chmod +x ~/.config/fabric/extensions/bin/track_packages.sh -``` - -### 2. Configure -Create `~/.config/fabric/extensions/configs/package-tracker.yaml`: -```yaml -name: package-tracker -executable: "~/.config/fabric/extensions/bin/track_packages.sh" -type: executable -timeout: "30s" -description: "Track system package changes" -version: "1.0.0" - -operations: - track: - cmd_template: "{{executable}}" - -config: - output: - method: stdout -``` - -### 3. Register & Run -```bash -# Register -fabric --addextension ~/.config/fabric/extensions/configs/package-tracker.yaml - -# Run -fabric -p "{{ext:package-tracker:track}}" -``` ## Extension Management Commands +### Add Extension +```bash +fabric --addextension ~/.config/fabric/extensions/configs/memory-query.yaml +``` + +Note : if the executable or config file changes, you must re-add the extension. +This will recompute the hash for the extension. + + ### List Extensions ```bash fabric --listextensions @@ -186,6 +161,25 @@ fabric --rmextension ``` Removes an extension from the registry. + +## Extensions in patterns + +``` +Create a pattern that use multiple extensions. + +These are my favorite +{{ext:word-generator:generate:3}} + +These are my least favorite +{{ext:word-generator:generate:2}} + +what does this say about me? +``` + +```bash +./fabric -p ./plugins/template/Examples/test_pattern.md +``` + ## Security Considerations 1. **Hash Verification** diff --git a/plugins/template/Examples/test_pattern.md b/plugins/template/Examples/test_pattern.md new file mode 100644 index 00000000..d3de195d --- /dev/null +++ b/plugins/template/Examples/test_pattern.md @@ -0,0 +1,8 @@ +These are my favorite +{{ext:word-generator:generate:3}} + +These are my least favorite +{{ext:word-generator:generate:2}} + +what does this say about me? +