# Big Chef A Go-based tool for modifying XML, JSON, and text documents using XPath/JSONPath/Regex expressions and Lua transformations. ## Features - **Multi-Format Processing**: - XML (XPath) - JSON (JSONPath) - Text (Regex) - **Node Value Modification**: Update text values in XML elements, JSON properties or text matches - **Attribute Manipulation**: Modify XML attributes, JSON object keys or regex capture groups - **Conditional Logic**: Apply transformations based on document content - **Complex Operations**: - Mathematical calculations - String manipulations - Date conversions - Structural changes - Whole ass Lua environment - **Error Handling**: Comprehensive error detection for: - Invalid XML/JSON - Malformed XPath/JSONPath - Lua syntax errors ## Usage Examples ### 1. Basic field modification ```xml 44.95 chef -xml "//price" "v=v*2" input.xml 89.9 ``` ### 2. Supports glob patterns ```xml chef -xml "//price" "v=v*2" data/**.xml ``` ### 3. Attribute Update ```xml chef -xml "//item/@price" "v=v*2" input.xml ``` ### 3. JSONPath Transformation ```json // Input { "products": [ {"name": "Widget", "price": 19.99}, {"name": "Gadget", "price": 29.99} ] } // Command chef -json "$.products[*].price" "v=v*0.75" input.json // Output { "products": [ {"name": "Widget", "price": 14.99}, {"name": "Gadget", "price": 22.49} ] } ``` ### 4. Regex Text Replacement Regex works slightly differently, up to 12 match groups are provided as v1..v12 and s1..s12 for numbers and strings respectively. A special shorthand "!num" is also provided that simply expands to `(\d*\.?\d+)`. ```xml Price: $15.00 Special Offer chef "Price: $!num Special Offer" "v1 = v1 * 0.92" input.xml Price: $13.80 Special Offer ``` ### 5. Conditional Transformation ```xml chef -xml "//item" "if tonumber(v.stock) > 0 then v.price = v.price * 0.8 end" input.xml ``` ## Installation ```bash go build -o chef main.go ``` ```bash # Process XML file ./chef -xml "//price" "v=v*1.2" input.xml # Process JSON file ./chef -json "$.prices[*]" "v=v*0.9" input.json ```