mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 22:34:56 +00:00
refactor: Restructure multi-language workflow plugins to match Python pattern
Each plugin now follows the standardized structure:
- category/plugin_name/plugin_name.{ext} - Implementation
- category/plugin_name/package.json - Plugin metadata
- category/package.json - Category manifest with "plugins" array
Languages restructured:
- Go: 31 plugins across 7 categories (math, string, logic, list, dict, var, convert)
- Rust: 55 plugins as individual crates in Cargo workspace
- C++: 34 header-only plugins with complete coverage
- Mojo: 11 plugins across 3 categories (math, string, list)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
13
workflow/plugins/cpp/string/string_trim/package.json
Normal file
13
workflow/plugins/cpp/string/string_trim/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "@metabuilder/string_trim",
|
||||
"version": "1.0.0",
|
||||
"description": "Trim whitespace from string",
|
||||
"author": "MetaBuilder",
|
||||
"license": "MIT",
|
||||
"keywords": ["string", "workflow", "plugin"],
|
||||
"main": "string_trim.hpp",
|
||||
"metadata": {
|
||||
"plugin_type": "string.trim",
|
||||
"category": "string"
|
||||
}
|
||||
}
|
||||
42
workflow/plugins/cpp/string/string_trim/string_trim.hpp
Normal file
42
workflow/plugins/cpp/string/string_trim/string_trim.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
/**
|
||||
* Workflow plugin: trim whitespace from string
|
||||
*/
|
||||
|
||||
#include "../../plugin.hpp"
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
namespace metabuilder::workflow::string {
|
||||
|
||||
inline PluginResult trim(Runtime&, const json& inputs) {
|
||||
auto text = inputs.value("text", std::string{});
|
||||
auto mode = inputs.value("mode", std::string{"both"});
|
||||
|
||||
auto ltrim = [](std::string& s) {
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
|
||||
return !std::isspace(ch);
|
||||
}));
|
||||
};
|
||||
|
||||
auto rtrim = [](std::string& s) {
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
|
||||
return !std::isspace(ch);
|
||||
}).base(), s.end());
|
||||
};
|
||||
|
||||
std::string result = text;
|
||||
|
||||
if (mode == "start") {
|
||||
ltrim(result);
|
||||
} else if (mode == "end") {
|
||||
rtrim(result);
|
||||
} else {
|
||||
ltrim(result);
|
||||
rtrim(result);
|
||||
}
|
||||
|
||||
return {{"result", result}};
|
||||
}
|
||||
|
||||
} // namespace metabuilder::workflow::string
|
||||
Reference in New Issue
Block a user