Package: rfilerunner
rfilerunnerrfilerunnerruns commands, similar tojustor a simple Makefile.
This installs anrexecutable into your PATH that reads from an rfile, which is a YAML file that runs commands in some interpreter (e.g. shell, Python).$pipinstallrfilerunner

$echo'something: |echo something'>rfile.yml

$r
somethingInstallationGet the latest release fromPyPipipinstallrfilerunner

r--helpor install the latest code from GitHubpip install git+https://github.com/goatmobile/rfilerunner.gitThis installs therfilerunnerpackage, which includes an executable calledrfileand an easier to type alias ofr(they are the same, you can deleterand userfileif it conflicts with something on your system).Quick StartCreate anrfile.ymlin a directory and define some commands:echo'hello: |echo hellogoodbye: |echo goodbye'>rfile.ymlRun it withr(orrfile):# rfilerunner picks the first command as the default$r
hello# specify the command by name$rgoodbye
goodbye# if possible, rfilerunner will guess based on the prefix$rgo
Assuming'go'isshortfor'goodbye'goodbyeShell Completions(fish shell only) Get shell completions based on the current directory$r--completions
Installcompletionsfor...?(y/n)y
Installedsuccessfully!FeaturesRun Bash / Python scripts with a quick and simple language for passing in arguments and creating helpful CLIsEasy conversion from a simpleMakefile(e.g. if it's just targets and shell commands without using any actual features ofmake, runsed 's/:$/: \|/g' Makefile > rfile.yml)Prefix-based command matching (e.g.r helis equivalent tor helloin most cases)Search through parent directories to find an rfileRun dependencies in parallel with# parallelWatch files and re-run commands on modifications (or catch errors and run some other command)Advanced UsageHelpComments at the start of the script can be used to specify arguments. If none is provided, a help text will be generated automatically.test1:|# some help textecho hitest2:|# shell: bash (some help text)echo hitest3:|# help: some help textecho hiThen$ r --help
usage: r [-h, --help] [-v, --verbose] [-r, --rfile rfile] COMMAND

rfile is a simple command runner for executing Python and shell scripts

available commands:
    test1     some help text (default)
    test2     some help text
    test3     some help textArgumentsYou can specify arguments which are passed to the running script. In Python, they are available via anargsvariable and in Shell they can be accessed from the environment (e.g.$MY_ARGor as positional arguments on the script (e.g.$1):test4:|# arg: something (does something)echo arg is: $SOMETHING$ r test4 --arg wow
arg is: wowPythonYou can also use Python instead ofbash/sh. A few modules are included by default and any args are in theargsvariable and can be accessed with a.(args areNoneif not provided)python:|# use Python! a smattering of modules are included by default# arg: helloprint(os)print(args.hello)print("neat")Other InterpretersAny interpreter that can be run like/path/to/intepreter a_filewill work as a# shell:, though only Python and shells will get arguments passed in correctly.ruby:|# shell: rubyputs "Hello from ruby"Parallel DependenciesWith# parallel, dependencies will be run in parallel each in their own thread.d:|# parallel# dep: a# dep: b# dep: ca:|yes hellob:|yes goodbyec:|yes meow# invoke default command 'd'$r
b|goodbye
c|meow
c|meow
c|meow# outputs from each dependency are interleaved with and prefixed with '<name> |'Watch FilesThe# watch:directive will make rfile watch the specified files and re-run the script on any changes. The argument towatchcan be a 1-liner shell script, float number of seconds to sleep, or another command. The environment variableCHANGEDwill contain the triggering file (or may be empty). For more advanced functionality you can use external tools to keep your scripts running in watch mode forever manually via something likeentrorWatchman.inline-watch:|# watch: find . -type fecho changed file: $CHANGEDuse-another-command:|# watch: find-filesecho changed file: $CHANGEDsleep-watch:|# watch: 1.4echo hellofind-files:|find . -type fFor long running commands it may be preferred to cancel their run before running the next event, this can be done via the# canceldirective.# Edits to `test.txt` will cause the running command to be killed and restartedlong:|# watch: echo test.txt# cancelecho hisleep 30echo byeCatchIf a watch command fails, you can specify another script/command to run on each failure.ERRORwill contain the output with stdout and stderr intermixed (ANSI color codes are removed, the full message can be found inERROR_COLOR).watch:|# watch: echo file.txt# catch: echo failed!exit 1watch2:|# watch: echo file.txt# catch: fallbackecho script failedexit 1fallback:|echo "Failed with message:" $ERROR