Easily customizable command runner made with Rust ๐Ÿฆ€

Related tags

Utilities wip
Overview

Header image (light theme) Header image (dark theme)

crates.io Codecov Clippy check Test with coverage Release

Easily customizable command runner made with Rust ๐Ÿฆ€

๐Ÿ“ฆ Usage

Install by the following command:

cargo install rxe

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 rxe
# Now rxe will use rxe.config.yml as the configuration file

๐Ÿ“ Examples

Create the following configuration:

cmd:
  test:
    args:
      type:
        choice: [core, frontend, types]
      snapshot:
        flag:

    run:
      echo "Executing the test for {type} {snapshot|true=(with snapshot)}"

and you can run the command like this:

$ rxe test --type core --snapshot
#...

If the arugment was somehow wrong against the configuration, the error is shown.

$ rxe test --type backend  # There is no `backend` in the choice for `type` argument.
Could not parse the command argument: The value of the argument is invalid: The value was not appropriate: 'backend' is not available as the choice.
Please check the argument you passed to `rxe`, or configuration file.
Exiting abnormally due to the above error.

๐Ÿ›  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

๐Ÿ”ญ Overview

The configuration file is written in YAML. The configuration looks like this:

cmd:
  {Command name here}:
    args:
      {argument name here}:
        {argument type here}:
          {some additional argument configuration if neccesary}
      # other arguments can continue.

    run: |
      echo "commands. Can include the placeholder."
      
  # other commands can continue.

๐Ÿ”– Arguments

    args:
      {name}:
        {type}:
          {some additional configuration}

Arguments for the command can be defined in the args. The argument has two information: name and type1. 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

run: |
  # The result assumes that the rxe is executed by following command line:
  #   rxe {command name} --arg "Some text" --flag

  # This is the placeholder
  echo "{arg}"     # => Some text
  
  # The placeholder can be omitted using "\"
  echo "\{arg}"    # => \{arg}
  
  # The placeholder is not omitted if there was more than two "\"
  echo "\\{arg}"   # => \Some text
  echo "\\\{arg}"  # => \\Some text
  
  # Some argument type like Flag type require more information, called Property.
  # Properties can be specified using "|".
  echo "{flag|true=enabled|false=disabled}"
                   # => 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}<"
$ rxe exec --name "Some text"
Filled: >some text<

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}<"
$ rxe exec --name "12345"
Filled: >12345<

$ rxe exec --name "abcde"
Could not parse the command argument: The value of the argument is invalid: The value was not appropriate: 'abcde' could not be parsed as the number (esp. f64)
Please check the argument you passed to `rxe`, or configuration file.
Exiting abnormally due to the above error.

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}<"
$ rxe exec --name
Filled 1: >specified<
Filled 2: >specified<

$ rxe exec
Filled 1: >not specified<
Filled 2: ><

$ rxe exec --name "bruh"
Could not parse the command argument: The value of the argument is invalid: The value of the argument should not be given.
Please check the argument you passed to `rxe`, or configuration file.
Exiting abnormally due to the above error.

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 and false 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}<"
$ rxe exec --name "rust"
Filled: rust

$ rxe exec --name "p"
Filled: python

$ rxe exec --name "ru"
Could not parse the command argument: The value of the argument is invalid: The value was not appropriate: 'ru' is too ambiguous. Type the choice longer
Please check the argument you passed to `rxe`, or configuration file.

Footnotes

  1. Constraint in the code. โ†ฉ

You might also like...
A bundler (mainly for TypeScript projects) made in Rust

TSAR A bundler (mainly for TypeScript projects) made in Rust. Also my first Rust Project! What does TSAR stand for Like phar (PHP Archive) or JAR (Jav

A replit.com scraper, designed to grab discord tokens. Made in Rust.

Scraper A discord token scraper, designed to scrape forks from replit.com. This script uses the Graphql api on replit to essentially pull forks. Setup

Analog subtractive synth (VST Plugin) made with Rust

Synja Analog subtractive synth (VST3 Plugin) made with Rust. More an experiment in making a VST and learning Rust than a production quality Synth, but

ฮป-calculus parser made by rust

Lambda Calculus Parser This is a parser for ฮป-calculus expressions. It takes a ฮป-terms as input, parses it and returns a JSON representation of the te

The axiom profiler for exploring and visualizing SMT solver quantifier instantiations (made via E-matching).

Axiom Profiler A tool for visualising, analysing and understanding quantifier instantiations made via E-matching in a run of an SMT solver (at present

A command-line tool collection to assist development written in RUST

dtool dtool is a command-line tool collection to assist development Table of Contents Description Usage Tips Installation Description Now dtool suppor

Command line interface to manage clipboard

cb Command line interface to manage clipboard How to install Pre-Compiled you can download a pre-compiled executable, then you should copy that execut

A Command Line OTP Authenticator application.

cloak A Command Line OTP (One Time Password) Authenticator application written in Rust that generates time-based and counter-based OTP codes. Motivati

Rs.aws-login - A command line utility to simplify logging into AWS services.

aws-login A command line utility to simplify logging into AWS accounts and services. $ aws-login use ? Please select a profile to use: โ€บ โฏ dev-read

Comments
  • ใ‚จใ‚นใ‚ฑใƒผใƒ—ใฎๆŒ™ๅ‹•ใ‚’ๅค‰ใˆใ‚‹

    ใ‚จใ‚นใ‚ฑใƒผใƒ—ใฎๆŒ™ๅ‹•ใ‚’ๅค‰ใˆใ‚‹

    ๅฅ‡ๆ•ฐๅ€‹ \ ใŒใ‚ใฃใŸใจใใซใ‚จใ‚นใ‚ฑใƒผใƒ—ใ™ใ‚‹ใ‚ˆใ†ใซใ—ใŸใ„๏ผŽ

    "{name}"     | FILLED
    "\{name}"    | \{name}
    "\\{name}"   | \FILLED
    "\\\{name}"  | \\{name}
    "\\\\{name}" | \\FILLED
    
    feature 
    opened by loxygenK 0
  • `short_hand` ใ‚’ใ‚ตใƒใƒผใƒˆใ™ใ‚‹

    `short_hand` ใ‚’ใ‚ตใƒใƒผใƒˆใ™ใ‚‹

    ไปฅไธ‹ใŒใงใใ‚‹ใจใ†ใ‚Œใ—ใ„

    -ab "123"
    
    • Constraint ใŒ Flag ใชใ‚‰๏ผŒa ใฎใ‚ˆใ†ใซไป–ใฎๅผ•ๆ•ฐใซใคใชใ’ใ‚‰ใ‚Œใ‚‹๏ผŽFlag ไปฅๅค–ใชใ‚‰ ParseError::MalformedLine
    • ๆœ€ๅพŒใฎๅผ•ๆ•ฐใฏใชใ‚“ใงใ‚‚ใ„ใ„๏ผŽใ“ใ“ใฏๆ—ขๅญ˜ใฎๅ‡ฆ็†ใ‚’ไฝฟใ„ใพใ‚ใ›ใใ†

    (Possibly) depends on #4

    feature 
    opened by loxygenK 0
Releases(0.1.0)
Owner
Flisan
Writes the frontend of web apps by React (Next.js) mainly. Interested in the back-end recently
Flisan
Source to relay.fedi.buzz: the customizable ActivityPub relay

buzzrelay A follow-only ActivityPub relay that connects to Mastodon's Streaming API. You don't need to run this yourself, just use the instance at rel

Astro 7 Jan 23, 2023
Convert Hygea calendar to an iCal file to easily import it to Google Calendar (Rust version)

Hygea to iCal Goal Hygea provides a calendar via PDF and an application called Recycle. I just wanted to use an iCal file to import it in my calendar.

Guillaume Quittet 2 Oct 28, 2021
PM-Tools - a simple Rust util to easily create server directories

PM-Tools PM-Tools is a simple Rust util to easily create server directories or plugins without the hassle of unzipping or creating directories Progres

null 2 Mar 19, 2022
A low-ish level tool for easily writing and hosting WASM based plugins.

A low-ish level tool for easily writing and hosting WASM based plugins. The goal of wasm_plugin is to make communicating across the host-plugin bounda

Alec Deason 62 Sep 20, 2022
Annotation to easily define ad-hoc / one-shot extension traits

Annotation to easily define ad-hoc / one-shot extension traits

Daniel Henry-Mantilla 2 Apr 19, 2022
Easily sync your clipboard between devices. This is a work in progress app.

Clipboard Sync Description Easily sync your clipboard between devices. This is a work in progress app. Stack Frontend: React Tauri isomorphic-ws TSX,

Steveplays 2 Mar 2, 2022
Easily add emojis to your git commit messages ๐Ÿ˜Ž

gimoji A CLI tool that makes it easy to add emojis to your git commit messages. It's very similar to (and is based on) gitmoji-cli but written in Rust

Zeeshan Ali Khan 12 May 29, 2023
Cargo subcommand to easily bootstrap nocode applications. Write nothing; deploy nowhere.

cargo-nocode No code is the best way to write secure and reliable applications. Write nothing; deploy nowhere. cargo-nocode aims to bring the nocode a

Orhun Parmaksฤฑz 29 Jul 1, 2023
A Bancho implementation made in Rust for the *cursed* stack.

cu.rs A Bancho implementation made in Rust for the cursed stack. THIS PROJECT IS REALLY UNFINISHED AND IN ITS EARLY STAGES A drag and drop replacement

RealistikOsu! 5 Feb 1, 2022
An annotated string type in Rust, made up of string slices

A string type made up of multiple annotated string slices.

Togglebit 3 Dec 29, 2022