Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
December 20, 2019 09:12 pm GMT

Show DEV: Run - Easily manage and invoke small scripts and wrappers (Written in Golang)

Introduction

Do you find yourself using tools like make to manage non build-related scripts?

Build tools are great, but they are not optimized for general script management.

Introducing Run:

GitHub : https://github.com/TekWizely/run

Run aims to be better at managing small scripts and wrappers, while incorporating a familiar make-like syntax.

Features

Here are a few of Run's features:

  • Terse, make-like syntax
  • Manage multiple script types: Bash, Python, Ruby, etc.
  • Automatic help text generation
  • Command scripts are executed in a single sub-shell, not like make's (default) behavior of executing each line of a recipe in a separate sub-shell.
  • Define cli options and have the values passed to your scripts as environment variables.

Runfile

Where make has the ubiquitous Makefile, run has the cleverly-named "Runfile"

By default, run will look for a file named "Runfile" in the current directory, exiting with error if not found.

See the project README for details on specifying alternative runfiles, as well as other special modes you might find useful.

Hello World Example

The project's README starts with a much simpler example and walks through the various features, but I thought I would share a more fleshed out example to demonstrate several of the features together:

Runfile

### Hello world example.# Prints "Hello, <name>".# OPTION NAME -n,--name <name> Name to say hello tohello:  echo "Hello, ${NAME:-World}"

list commands

$ run listCommands:  list     (builtin) List available commands  help     (builtin) Show Help for a command  hello    Hello world example.Usage:       run [-r runfile] help <command>          (show help for <command>)  or   run [-r runfile] <command> [option ...]          (run <command>)

show help for hello command

$ run help hellohello:  Hello world example.  Prints "Hello, <name>".Options:  -h, --help        Show full help screen  -n, --name <name>        Name to say hello to

invoke hello command with no options

$ run helloHello, World

invoke hello command with options

$ run hello --name=Newman$ run hello -n NewmanHello, Newman

Installing

Currently, installing requires using go get, but there is an active PR for a brew formula and I'm also working on a PKGBUILD file.

Conclusion

If you're at all interested in managing task runners and scripts, I hope you will give my project a try.

I am happy to answer any questions you might have.

Thank you for your time and Happy Holidays!

-TekWizely ( https://github.com/TekWizely )

[edit] Typos


Original Link: https://dev.to/tekwizely/show-dev-run-easily-manage-and-invoke-small-scripts-and-wrappers-written-in-golang-1lp9

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To