#file #time #compare #command-line-tool #modification #glob

app dirtcomp

A command line utility to compare modification times between file globs

2 releases

0.1.1 Feb 28, 2024
0.1.0 Feb 28, 2024

#509 in Filesystem

GPL-3.0-only

20KB
252 lines

The Directory Time Comparator (dirtcomp)

Motivation

This utility allows you to compare two globs to determine which describes newer file(s). Its motivating purpose is the reproduction of file dependencies (a useful part of the Makefile feature called "rules") in Just. More generally, though, this utility can be used in any scripting context on any system that the Rust glob crate supports.

Installation

Cross-platform builds are not yet configured. That will come. Until then, you can install by using cargo install dirtcomp. If you prefer, you can also clone the repository and build it using cargo build --release or by running just install [path]. See the justfile for more options.

Usage

There are two subcommands currently defined:

  1. check accepts two globs as positional arguments, <BASE> and <TARGET>.
  2. multi-check accepts repeated arguments, --base <GLOB> and --target <GLOB>.

In both cases, if the base globs describe newer files, a successful Unix status code (0) is returned. If the targets are newer, an "error" status code 1 is returned. Other status codes represent genuinely erroneous states.

A reasonable example, from one of my other projects, is:

#!/bin/sh
if $(dirtcomp check 'src/**/*.ts' 'dist/**/*'); then
    pnpm tsc
else
    echo "Nothing to do; skipping compilation."
fi

Dependencies

~3–11MB
~147K SLoC