The Auto-Command-Wrapper
README.md

Auto Command Wrapper #

A wrapper for binaries that reads their output and executes commands based on regular expressions defined in a ron-configuration file.

Installation #

acw can be installed either directly...

cargo install --git https://git.sr.ht/~sntx/acw --locked

... or you can clone the repo beforehand and install with...

git clone https://git.sr.ht/~sntx/acw && cd acw
cargo install --path . --locked

Usage #

Usage: acw <COMMAND> [CONFIG_PATH]

Arguments:
  <COMMAND>      Command to wrap
  [CONFIG_PATH]  Path to the configuration file [default: config.ron]

Options:
  -h, --help     Print help
  -V, --version  Print version

Configuration #

The configuration looks like the following:

[
    Command(
        regex: "^ping$",
        command: "echo pong",
    ),
    Command(
        regex: "^(\d{6}) said: \/help$",
        command: "echo User with id:'{}' asked for help",
    ),
]

Please note the following:

  • The amount of groups in the regex (()) and amount substitutions ({}) in the command need to be equal.
  • All Commands with a match will be executed!