witch

command module
v0.0.0-...-d46617c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 14 Imported by: 0

README

witch

Dead simple watching

Build Status Go Report Card

screenshot

Description

Detects changes to files or directories and executes the provided shell command. That's it.

Features:

  • Supports double-star globbing
  • Detects files / directories added after starting watch
  • Watch will persist if executed shell command returns an error (ex. compile / linting errors)
  • Awesome magic wand terminal spinner

Note: Uses polling to work consistently across multiple platforms, therefore the CPU usage is dependent on the efficiently of your globs. With a minimal effort your watch should use very little CPU. Will switch to event-based once fsnofity has matured sufficiently.

Dependencies

Requires the Go programming language binaries with the GOPATH environment variable specified and $GOPATH/bin in your PATH.

Installation

go get github.com/geotime/witch

Usage

witch --cmd=<shell-command> [--watch="<glob>,..."] [--ignore="<glob>,..."] [--interval=<milliseconds>]

Command-line args:

Flag Description
cmd Shell command to execute after changes are detected
watch Comma separated globs to watch (default: ".")
ignore Comma separated globs to ignore (default: "")
interval Scan interval in milliseconds (default: 400)
max-token-size Max output token size in bytes (default: 2048000)
no-spinner Disable fancy terminal spinner (default: false)

Globbing

Globbing rules are the same as doublestar which supports the following special terms in the patterns:

Special Terms Meaning
* matches any sequence of non-path-separators
** matches any sequence of characters, including path separators
? matches any single non-path-separator character
[class] matches any single non-path-separator character against a class of characters (see below)
{alt1,...} matches a sequence of characters if one of the comma-separated alternatives matches

Any character with a special meaning can be escaped with a backslash (\).

Character Classes

Character classes support the following:

Class Meaning
[abc] matches any single character within the set
[a-z] matches any single character in the range
[^class] matches any single character which does not match the class

Any globs resolved to a directory will be have all contents watched.

Example

witch --cmd="make lint && make fmt && make run" --watch="main.go,api/**/*.go"

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL