shim

Crates.ioshim
lib.rsshim
version0.1.4
sourcesrc
created_at2022-10-25 23:45:29.280562
updated_at2023-01-01 23:23:46.687134
descriptionCreate shims for executables from config files
homepagehttps://github.com/adam-gaia/shim
repositoryhttps://github.com/adam-gaia/shim
max_upload_size
id697397
size59,608
Adam Gaia (adam-gaia)

documentation

README

Shim

Create shims for executables from config files.

Stability Warning

API may change wildly until while the major version number is 0. Once this crate's version hits 1.0.0 api changes will only happen with major version bumps.

Installation

With Cargo

cargo install shim

Usage

Cli

shim --help

Shim config files

Motivation

Condensing configuration

My git configuration was scattered over too many places

  • Git allows arbitrary commands to be named with prefix git- and git will

  • My git config file defined aliases

[alias]
url = remote get-url origin
root = rev-parse --show-toplevel
commit = !cz commit
cz = !cz commit
  • My bashrc has a function that
    • adds pre/post hooks globally, for all git commands
    • overrides some git subcommands
function git() {
  # Run pre-commit first for immediate feedback
  pre-commit # TODO: only run on some git commands

  # Override functionality based on the first argument, the subcommmand
  case "$1" in
    'commit')
      cz commit
      ;;
    'init'|clone)
      # Run command before creating a new repo on filesystem
      git-track-repos --quiet "$@"
      # Unlike other commands, make sure to run the git operation still
      git "$@"
      ;;
    *)
      # Fall back to actual git for everything else
      git "${@}"
      ;;
  esac

  # Run these after any git operation completes
  git-track-repos # This is a program I wrote to keep track of all repos I've cloned
}
  • Git hooks

Forking fewer times when calling git

I've created quite a few hooks. I've written a tool for some of my hooks (TODO: publish that tool and link here) in rust. I plan for shim to be able to load shims from dynamic libraries instead of forking a bunch of processes

Commit count: 26

cargo fmt