DEV Community

TekWizely
TekWizely

Posted on

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 to
hello:
  echo "Hello, ${NAME:-World}"
Enter fullscreen mode Exit fullscreen mode

list commands

$ run list

Commands:
  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>)
Enter fullscreen mode Exit fullscreen mode

show help for hello command

$ run help hello

hello:
  Hello world example.
  Prints "Hello, <name>".
Options:
  -h, --help
        Show full help screen
  -n, --name <name>
        Name to say hello to
Enter fullscreen mode Exit fullscreen mode

invoke hello command with no options

$ run hello

Hello, World
Enter fullscreen mode Exit fullscreen mode

invoke hello command with options

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

Hello, Newman
Enter fullscreen mode Exit fullscreen mode

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

Top comments (1)

Collapse
 
ben profile image
Ben Halpern

This seems really useful, well done!