Git Product home page Git Product logo

repvar's Introduction

repvar - Variable replacing, UNIX-style text filter

License: AGPL-3.0-or-later REUSE status Repo Package Releases Documentation Releases Dependency Status Build Status

In cooperation with FabCity Hamburg In cooperation with Open Source Ecology Germany

A tiny CLI tool that replaces variables of the style ${KEY} in text with their respective value. It can also be used as a rust library.

For the CLI tool, the variables can be read from the environment or be directly supplied through CLI switches, like -Dkey=value.

NOTE
The author is a rust-newb. This crate probably only makes sense for himself, and it is not using the power of rust as should be. It also could probably be written in just 10 lines of code, using one or two regexes, not loosing any performance.

Usage

Simplisitc

$ export KEY_A="replacement"   # setting an env.-variable
$ echo 'Text ${KEY_A}.' \      # input text
    | repvar --env             # replacing variables
Text replacement.              # output

Slightly more elaborate

$ export first="the environment"
$ echo 'Variables from ${first}, ${second}, ${not_supplied} and $${quoted}.' \
    | repvars --env -D"second=the CLI"
Variables from the environment, the CLI, ${not_supplied} and ${quoted}.

More usage info can be seen when running:

repvars --help

Building

# To get a binary for your system
cargo build --release

# To get a 64bit binary that is portabel to all Linux systems
scripts/build

Testing

To run unit-, doc- and integration-tests:

scripts/test

Similar projects

Funding

This project was funded by the European Regional Development Fund (ERDF) in the context of the INTERFACER Project, from August 2021 (project start) until March 2023.

Logo of the EU ERDF program

repvar's People

Contributors

hoijui avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.