fiddlerwoaroof / sigexec

A simple utility that runs a command with each line sent over a socket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

socket-based command runner

Introduction

Run a command everytime a line is written to a unix socket, passing the line written as the last argument to the command. Useful in an after-save-hook in emacs to run tests after the buffer is saved. Unlike file-watchers, this allows more precise control of when the tests are run, reducing the amount of time spent configuring ignore files and waiting for spurious reruns.

Building

Choose either building with zig:

zig build --verbose

Or nix:

nix build github:fiddlerwoaroof/sigexec

One can also run the flake’s default app like:

nix run github:fiddlerwoaroof/sigexec <socket> <command...>

Usage

rm /tmp/jest.sock ; $OLDPWD/zig-out/bin/zig-test /tmp/jest.sock npx jest --

Full-stack example:

In one terminal:

% nix run github:fiddlerwoaroof/sigexec /tmp/bar.sock echo NOTICE ME: input:
# output:
# warning: listening at /tmp/bar.sock
#
# NOTICE ME: input: 4

In another terminal:

# in another terminal:
% echo 4 | socat - unix-connect:/tmp/bar.sock
# ACK!

About

A simple utility that runs a command with each line sent over a socket


Languages

Language:Zig 55.5%Language:Nix 34.9%Language:Shell 9.6%