Skip to content
/ runt Public

Simple commandline utility to make configuration files executable

License

Notifications You must be signed in to change notification settings

yawn/runt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Run template (runt)

Rust

runt is a simple commandline utility to make configuration files executable.

Example

Considering a configuration file s3.yml with the executable bit set:

#! /usr/local/bin/runt -v
# aws cloudformation deploy
#   --template-file $RUNT_TAIL
#   --stack-name ${1-test}
#   --capabilities CAPABILITY_IAM
#   --parameter-overrides Foo=bar
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31

Parameters:
  Foo:
    Type: String

Resources:
  HelloBucket:
    Type: AWS::S3::Bucket

When executing this file, runtwill

  1. open the file it was invoked on as part of the shebang, in this case s3.yml
  2. collect all lines following the shebang that start with # into one line (the head) - note that the length of the head is allowed to exceed the length of a shebang line
  3. copy the following lines into a temporary file (the tail)

runt then provides an env with the following variables added:

  • $RUNT_TAIL (can be overriden with -t or --env-for-tail) with the absolute path to the tail
  • $@, $0..n and $# are overriden with optional arguments passed to the file with $0 being set to the name of the file

This env is then used to execute the head.

Configuration options

runt has very few configuration options:

  • -t, --env-for-tail (default: $RUNT_TAIL) specifies the tail location
  • -k, --keep-tail will flag the temporary tail file as "do not delete"
  • -v, --verbose will output some debug information while running

Installation

On Mac OS with brew run brew tap yawn/taps and the brew install runt.

Currently no other platforms are supported. Feel free to open a PR if interested.

About

Simple commandline utility to make configuration files executable

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages