DEV Community

TekWizely
TekWizely

Posted on

Run v0.7.2 - Easily manage and invoke small scripts and wrappers

About

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.

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

Quick Links: Project Page | Examples | Installing | Releases


Project Update - v0.7.2

You can read about the new features and bug fixes below.

If you've been following run, I hope you'll find these updates useful.

If this your first time reading about run, and 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,

-TekWizely


New Features

Assertions

Assertions let you check against expected conditions, exiting with an error message when checks fail.

Assertions have the following syntax:

ASSERT <condition> [ "<error message>" | '<error message>' ]
Enter fullscreen mode Exit fullscreen mode

Note: The error message is optional and will default to "Assertion failed" if not provided

Condition

The following condition patterns are supported:

  • [ ... ]
  • [[ ... ]]
  • ( ... )
  • (( ... ))

Assertion Example

Runfile

##
# Not subject to any assertions
world:
    echo Hello, World

# Assertion applies to ALL following commands
ASSERT [ -n "${HELLO}" ] "Variable HELLO not defined"

##
# Subject to HELLO assertion, even though it doesn't use it
newman:
    echo Hello, Newman

##
# Subject to HELLO assertion, and adds another
# ASSERT [ -n "${NAME}" ] 'Variable NAME not defined'
name:
    echo ${HELLO}, ${NAME}
Enter fullscreen mode Exit fullscreen mode

example with no vars

$ run world

Hello, World

$ run newman

run: Variable HELLO not defined

$ run name

run: Variable HELLO not defined
Enter fullscreen mode Exit fullscreen mode

example with HELLO

$ HELLO=Hello run newman

Hello, Newman

$ HELLO=Hello run name

run: Variable NAME not defined
Enter fullscreen mode Exit fullscreen mode

example with HELLO and NAME

$ HELLO=Hello NAME=Everybody run name

Hello, Everybody
Enter fullscreen mode Exit fullscreen mode

Note: Assertions only apply to commands and are only checked when a command is invoked. Any globally-defined assertions will apply to ALL commands defined after the assertion.

Ignoring Script Lines

You can use a # on the first column of a command script to ignore a line:

Runfile

hello:
    # This comment WILL be present in the executed command script
    echo "Hello, Newman"
# This comment block WILL NOT be present in the executed command script
#   echo "Hello, World"
    echo "Goodbye, now"
Enter fullscreen mode Exit fullscreen mode

Note: Run detects and skips these comment lines when parsing the runfile, so the # will work regardless of what language the script text is written in (i.e even if the target language doesn't support # for comments).

Top comments (0)