Recipes

An Anteater recipe is an XML-based script file (with a .recipe extension) used by the Anteater tool to automate tasks, process data, and orchestrate workflows. Each recipe defines a sequence of commands, variables, and operations that Anteater executes to perform actions such as data transformation, system configuration, integration, and more.

Anteater recipes are flexible and do not require an XML Schema (XSD) or DTD for validation. This allows for a wide range of command combinations, but it’s important to follow the expected syntax for successful execution.

Recipe Editor

Anteater includes a Recipe Editor within its Desktop application, providing a user-friendly interface for creating, editing, and managing recipes. The editor simplifies defining commands, managing variables, and structuring workflows—no manual XML editing required.

Access the Recipe Editor through the Anteater Desktop application. For more details, see the Recipe Editor Documentation.

Key Features of Anteater Recipes

  1. XML-Based Structure: Recipes are written in XML, using the .recipe extension, and provide a structured way to define tasks and their relationships.
  2. Command-Driven: Commands are the core building blocks, representing actions like variable definition, data manipulation, file operations, and output generation.
  3. Variable Support: Recipes support variables of various types (text, array, map, JSON) for storing and processing data.
  4. Dynamic and Reusable: Recipes can handle dynamic inputs/outputs and are reusable across different workflows.
  5. Extensible: New commands and plugins can be added to extend Anteater’s capabilities for custom use cases.

Anteater Recipe Example

<Recipe name="Example Recipe">
  <!-- Define a text variable -->
  <Var name="WelcomeMessage" type="text" init="console">
    Welcome to Anteater Recipes!
  </Var>
  <Out name="WelcomeMessage" />

  <!-- Define an array -->
  <Var name="Items" type="array">
    <item>Item 1</item>
    <item>Item 2</item>
    <item>Item 3</item>
  </Var>
  <Out name="Items" />

  <!-- Define a map -->
  <Var name="Config" type="map">
    <item key="host">localhost</item>
    <item key="port">8080</item>
  </Var>
  <Out name="Config" />

  <!-- Remove a variable -->
  <Remove name="WelcomeMessage" />
</Recipe>

What Can You Do with Anteater Recipes?

  • Data Transformation: Manipulate and format data, such as splitting strings, mapping keys, or converting formats.
  • Configuration Management: Define and manage configuration data for applications or systems.
  • Workflow Automation: Automate tasks like data processing, file generation, or API integration using a rich set of commands.
  • Dynamic Inputs/Outputs: Handle user input and generate outputs based on recipe logic.
  • Integration: Connect with external systems, APIs, or plugins to extend functionality.

Base Commands

Anteater offers a wide range of commands, grouped by their primary functionality. Below is a categorized overview with examples:

1. Variable and Data Management

  • Var: Define or update variables, Example.

    <Var name="username" value="admin"/>
    
  • Calculate: Evaluate expressions, Example.

    <Calculate name="result" expressions="2 + 2"/>
    
  • Append: Add items to arrays, Example.

    <Append name="myArray" value="newItem"/>
    
  • Remove: Delete variables or files, Example.

    <Remove name="tempVar"/>
    
  • Inc: Increment numeric variables, Example.

    <Inc name="counter" increase="1"/>
    
  • Rnd: Generate random values, Example.

    <Rnd name="uuid" type="uuid"/>
    

2. Control Flow

  • If: Conditional logic, Example.

    <If name="status" equals="success">
      <Out>Success</Out>
      <Else>
        <Out>Failure</Out>
      </Else>
    </If>
    
  • While: Loop while a condition is true, Example.

    <While name="counter" notEqual="10">
      <Inc name="counter" increase="1"/>
    </While>
    
  • Loop: Iterate over collections or a set number of times, Example.

    <Loop numbers="5">
      <Out>Iteration</Out>
    </Loop>
    
  • Break / Stop: Exit loops or stop execution, Example, Example.

    <Break/>https://sourceforge.net/p/anteater/code/HEAD/tree/trunk/anteater-cli/src/manual-test/ae/recipes/commands/Break.recipe
    <Stop/>
    

3. Input/Output and User Interaction

  • Out: Output variable values or text, Example.

    <Out name="result"/>
    
  • Confirm: Request user confirmation, Example.

    <Confirm message="Proceed?" name="userConfirm"/>
    
  • Clipboard: Copy variable value to clipboard, Example.

    <Clipboard name="username"/>
    

4. String and Array Operations

  • Replace: Replace characters or patterns, Example.

    <Replace name="textVar" regex="\\d+" replacement="number"/>
    
  • Trim: Remove whitespace, Example.

    <Trim name="textVar"/>
    
  • Tokenizer: Split strings, Example.

    <Tokenizer name="csvLine" delim=","/>
    
  • ArrayElement: Get array element by index, Example.

    <ArrayElement name="item" array="myArray" elementId="2"/>
    
  • ArraySize: Get array or string length, Example.

    <ArraySize name="arrayLength" array="myArray"/>
    

5. File and Directory Operations

  • Listdir: List files in a directory, Example.

    <Listdir path="." name="fileList"/>
    
  • Load: Load data from files or URLs, Example.

    <Load name="fileContent" file="data.txt"/>
    
  • Remove: Delete files, Example.

    <Remove file="oldfile.txt"/>
    

6. Network and HTTP Operations

  • Get: HTTP GET request, Example.

    <Get name="response" url="http://example.com/api"/>
    
  • Post: HTTP POST request, Example.

    <Post name="response" url="http://example.com/api" body="{'key':'value'}"/>
    
  • Request: Custom HTTP or socket request, Example.

    <Request method="get" response="respVar" host="http://example.com"/>
    

7. System and Process Control

  • Command: Execute system commands, Example.

    <Command os=".*" cmd="echo Hello World"/>
    
  • Wait: Pause execution, Example.

    <Wait delay="2s"/>
    

8. Advanced and Utility Commands

  • Extern: Use external processors, Example.

    <Extern class="CustomProcessor">
      <!-- custom commands -->
    </Extern>
    
  • Task: Run other recipes or group commands, Example.

    <Task name="OtherRecipe"/>
    
  • About: Add recipe metadata, Example.

    <About>
      <description>Sample recipe description.</description>
    </About>
    
  • Comment: Add comments.

    <!-- This is a comment -->
    

9. Other Utilities

  • Date: Get or format dates, Example.

    <Date name="now" format="yyyy-MM-dd HH:mm:ss"/>
    
  • Formater: Format variables, Example.

    <Formater name="xmlVar" type="xml"/>
    
  • Parse: Parse data formats, Example.

    <Parse name="jsonVar" source="rawData" type="json"/>
    

10. Threading and Concurrency

  • Runnable / Threads: Define and run code in threads, Example.
    <Runnable name="myTask">
      <Out>Running in thread</Out>
    </Runnable>
    <Threads name="myTask" numbers="2" multi="true"/>
    

11. Network Utilities

  • NetworkInterfaces: List network interfaces, Example.
    <NetworkInterfaces name="interfaces"/>
    

12. Miscellaneous

  • Pragma: Set execution options, Example.

    <Pragma event="console-input" action="default"/>
    
  • Note: Add notes with connections, Example.

    <Note name="info" connection="db">Database connection info</Note>
    

Why Use Anteater Recipes?

  • Flexibility: Highly configurable for a wide range of use cases.
  • Reusability: Recipes can be reused across projects and workflows.
  • Automation: Automate repetitive tasks, reducing manual effort.
  • Extensibility: Add new commands and plugins as your needs evolve.

Further Resources

For a complete list of supported commands and advanced features, visit the official documentation:
Anteater Plugins and Commands Documentation

Tip: When writing recipes, always escape <, >, and " in attribute values as &lt;, &gt;, and &quot; respectively.