run commands when a file is modified or upon receiving TCP/UDP packets

Related tags

Cryptography witness
Overview

Witness

Command line utility which lets you execute arbitrary commands in response to:

  • File changes
  • UDP packets and TCP connections

Installation

Using Cargo

This requires the Rust toolchain to be installed.

cargo install witness

Motivation

While writing code it is often necessary to run you compiler/build tool as you are editing a file in order to catch errors. Switching back and forth between your editor and terminal can quickly become tedious and time-consuming.

witness helps speed up this workflow: all you have to do is save the file you are currently working on, and watch the command run.

Usage

Wait for a file to be modified and run you build tool of choice:

$ witness cargo build

Only watch for files with these specific extensions

$ witness -e rs cargo build

Watch files within a specific directory

$ witness --path src cargo build

Note that anything put within quotes ("...") will be passed to your default shell, meaning everything you are familiar with from your terminal will work here as well! This includes pipes, which can be useful if you want to see the top errors first:

witness "cargo check |& less"

Other Triggers

witness was built around the idea that you might have more complex workflows than just edit-compile-debug. In addition to file system changes, witness can also be configured to look for IP requests on UDP and TCP sockets. This can be helpful if you need commands running in one terminal to trigger commands in other terminals.

Below we will look into a typical workflow involving the use of a web server. For this use case we keep one terminal open for a edit-compile-debug workflow, and another terminal for actually running our server in the background.

In our terminal running the server we run the following:

$ witness --udp=1234 cargo run

This tells witness to rebuild and rerun your server every time there's a UDP packet on port 1234.

In our other terminal we then run:

$ witness "cargo check && witness --trigger --udp=1234"

Which will run cargo check repeatedly as we make changes to our code. If our code successfully compiled, witness then triggers the other terminal by sending a UDP packet to port 1234.

You might also like...
Rust-based file hashing program

Rash A file hashing tool written in Rust Command line application for calculating the hash value of a file. Rash uses the RustCrypto collection of lib

A young, simple and naive file crypto lib based on AES.

naive-file-crypto A young, simple and naive file crypto lib based on AES. The MAC implementation is not standard GCM, so it may be vulnerable. All cpu

The fallen leaves tell a story... of a colorful file tree visualizer for the command-line.
The fallen leaves tell a story... of a colorful file tree visualizer for the command-line.

Erdtree A bLazInGlY fAsT, simplified version of the ancient tree command which displays a colorful depth indented listing of files with their memory s

A secure file encryption utility, written in rust.

Dexios Dexios What is it? Building notes Checksums Performance Output file sizes Environment Variables Key Inputs Usage Examples To Do What is it? Dex

 DexiosGUI - Simple cross-platform drag-and-drop Dexios file encryption
DexiosGUI - Simple cross-platform drag-and-drop Dexios file encryption

DexiosGUI Simple cross-platform drag-and-drop Dexios file encryption. Latest Windows x64 release is here. DexiosGUI is a Qt/C++ app for encrypt and de

Generate IPv4 12th order Hilbert heatmaps from a file of IPv4 addresses.
Generate IPv4 12th order Hilbert heatmaps from a file of IPv4 addresses.

Rustified IPv4 Heatmap This is a pure Rust version of the C ipv4-heatmap utility originally published by The Measurement Factory and updated forever-a

Rust API Client for ImageKit.io a file storage and image processing service

Rust API Client for ImageKit.io a file storage and image processing service Usage You must retrieve your Public and Private Keys from the ImageKit Dev

Program to determine the password of an encrypted ZIP file via dictionary attack.

zip-dict-attack Program to determine the password of an encrypted ZIP file via dictionary attack. Inspired by this article. Usage Cargo is used to bui

Chargo is a tool for file encryption/decryption. It's based on Argon2 and ChaCha20Poly1305 algorithms.

| Documentation Chargo is a tool for file encryption/decryption with password. It's based on Argon2 and ChaCha20Poly1305 algorithms. From arg2u with ♥

Owner
Christofer Nolander
Christofer Nolander
Unified directories for different use cases of an application, providing standard directories for local development, when run as service or when run by a user.

UniDirs Unified directories for different use cases of an application, providing standard directories for local development, when run as service or wh

Dominik Nakamura 3 Sep 30, 2022
a simple rust service for Scheduling commands execution on time basis, an easy alternative to cron

Tasker A Simple crate which provides a service and a configuration API for genrating commands based tasks ,on time basis. Installation build from sour

Daniel Madmon 5 Jun 1, 2023
This is a template to build secret contracts in Rust to run in Secret Network

Secret Contracts Starter Pack This is a template to build secret contracts in Rust to run in Secret Network. To understand the framework better, pleas

Ethan Gallucci 1 Jan 8, 2022
A template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it.

CosmWasm Starter Pack This is a template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it. To understan

null 1 Mar 7, 2022
Smart Contract built in Rust to run inside Cosmos SDK module on all chains that enable it

CoinSwap is a Smart Contract that is built on the terra blockchain and can be used to swap cryptocurrencies such as LUNA, UST, TerraUSD, Anchor, Mirror Protocol, LUNI and other CW20 tokens. The Project also contains a smart contract which works as a analysis tool for the gas fees on the Terra Blockchain.

Prajjwal Chittori 9 Oct 11, 2022
An experimental fork of a16z's Helios Ethereum client which can run its network traffic over the Nym mixnet

Helios (Nym mixnet fork) Helios is a fully trustless, efficient, and portable Ethereum light client written in Rust. This fork of Helios includes nasc

Nym 4 Mar 3, 2023
Run unpatched dynamic binaries on NixOS

nix-ld-rs Run unpatched dynamic binaries on NixOS. This is a rewrite of nix-ld in Rust, with extra functionalities. It's intended to be upstreamed at

Nix community projects 13 Jun 26, 2023
A file storage service

hashfs A file storage service How to use it? Start up the service at terminal # You can specify the storage root path and access domain when you start

null 17 Dec 18, 2021
A Rust binary for file encryption to multiple participants.

Kaspa-miner A Rust binary for file encryption to multiple participants. Installation From Sources With Rust's package manager cargo, you can install k

Elichai Turkel 31 Dec 30, 2022
NymDrive is a complete, end-to-end encrypted file syncing daemon that runs over the Nym network.

NymDrive NymDrive is a complete, end-to-end encrypted file syncing daemon that runs over the Nym network. Features Active file monitoring of changes i

Hans Bricks 16 Jul 12, 2022