Easily customizable command runner made with Rust 🦀
📦 Usage
Install by the following command:
Or build from the source.
git clone https://github.com/loxygenK/rxe
cargo run
🏃♀️ Running scripts
Prepare rxe.yaml
(or rxe.yml
, .rxe.yml
, .rxe.yaml
) in the same current directory, and run:
rxe (your command) (and some arguments)
For more detailed explanation, see Examples or Creating configuration.
🔎 Specifying the configuration
By setting the environment variable RXE_CONFIG
, you can use any name for the configuration.
RXE_CONFIG=rxe.config.yml
# Now rxe will use rxe.config.yml as the configuration file
📝 Examples
Create the following configuration:
cmd:
test:
args:
type:
choice:
snapshot:
flag:
run:
echo "Executing the test for {type} {snapshot|true=(with snapshot)}"
and you can run the command like this:
#...
If the arugment was somehow wrong against the configuration, the error is shown.
🛠 Creating configuration
TL;DR:
- There are four types for the argument, text, number, flag, choice.
- The value of the arguments is filled into the placeholder which is the text surrounded by
{}
.- It can be escaped using
\
. Please see the placeholder section for the behavior around the escaping
- It can be escaped using
🔭 Overview
The configuration file is written in YAML. The configuration looks like this:
cmd:
:
args:
:
:
# other arguments can continue.
run: |
echo "commands. Can include the placeholder."
# other commands can continue.
🔖 Arguments
args:
:
:
Arguments for the command can be defined in the args
. The argument has two information: name and type[^1]. Please see types for available types.
📝 Run script
run: |
echo "commands"
Script is defined in the run
. Script can include placeholders for embedding the value of arguments.
Placeholder
|
# The result assumes that the rxe is executed by following command line:
# rxe {command name} --arg "Some text" --flag
# This is the placeholder
# The placeholder can be omitted using "\"
# The placeholder is not omitted if there was more than two "\"
# Some argument type like Flag type require more information, called Property.
# Properties can be specified using "|".
# => enabled
Placeholder is the text that the surrounded by {}
. It contains informations: name and properties. The placeholder is replaced by the value of argument (called filling).
The placeholder syntax looks like following:
{name of the argument|property name=config value|property name=config value|...}
For example, for the placeholder {flag|true=enabled|false=disabled}
...
-
The value of the argument "flag" is filled.
The following properties will be used for filling:
true
:enabled
false
:disabled
🧩 Types
There is four types currently.
Text type
cmd:
exec:
args:
name:
text:
run: |
echo "Filled: >{name}<"
Any text. If no value is specified, rxe fails before executing the script specified in run
.
Number type
cmd:
exec:
args:
name:
number:
run: |
echo "Filled: >{name}<"
)
Any number. If non-numeric value is used (like abcde
or 0x12345
) or no value is specified, rxe fails.
Flag type
cmd:
exec:
args:
name:
flag:
run: |
echo "Filled 1: >{name|true=specified|false=not specified}<"
echo "Filled 2: >{name|true=specified}<"
The argument becomes flag. The arguments can be omitted, and takes no value. If any value was passed to the flag type argument, rxe fails.
Properties
name | value | Optional? |
---|---|---|
true |
The text that should be filled when the argument is used. | Yes |
false |
The text that should be filled when the argument is not used. | Yes |
true
andfalse
can be specified in the same time, but cannot be omitted in the same time.
Choice type
cmd:
exec:
args:
name:
choice:
- rust
- ruby
- python
run: |
echo "Filled: >{name}<"
[^1]: Constraint
in the code.