watcher

command module
v0.0.0-...-19e8dd2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

README

Watcher - Develop your programs easily

Watcher watches all the files present in the directory it is run from of the directory that is specified while running it and whenever a file is changed or a file is created/deleted from the directory, it runs the command specified while running it or a default command that it recognises from the contents of the current directory.

Features

  • Choose which directory to watch for file changes
  • Specify amount of time to wait before running the command after a file change occurs
  • List the files that are being watched
  • Choose whether to run the command on startup
  • Set the maximum number of files that can be watched
  • Supports never ending processes such as dev servers as the command
  • Have a default ignore list
  • Press keys for force refreshing even when file change is not detected
  • Automatically recognize commands for popular project structure

Arguments

Command

The command you want to run when any file changes

watcher --cmd '<cmd>'
or
watcher -x '<cmd>'
Directory

The directory that you want watcher to watch for file changes. (default: ".")

watcher --dir '<dir>'
Ignore

The files that you want to ignore. It also supports file globbing.

watcher --ignore '<files>'
Ignore File

A file that contains the files that you want to ignore. It follows the gitignore file syntax

watcher --ignore-file '<file-name>'
Hidden

Whether the hidden files should also be watched for file changes. (default: true)

watcher --hidden false
Clear

Whether to clear the terminal every time the command is rerun due to changed. (default: true)

watcher -c
or
watcher --clear
Delay

The amount of time to wait before running the specified command after a file change occurs. (default: 500ms)

watcher --delay 1000ms
Run on Start

Whether the specified command should run when watcher has first started. (default: true)

watcher --run-cmd-on-start false
or
watcher -r false
List on Start

Whether the list of files being watched should be printed when watcher has first started. (default: false)

watcher --list-on-start true
Limit

The maximum number of files that can be watched. (default: 10000)

watcher --limit 50000
or
watcher -l 50000

⚠️ Every system has a maximum value which cannot be exceeded. To find it look at:

  • Linux: /proc/sys/fs/inotify/max_user_watches contains the limit, reaching this limit results in a "no space left on device" error.
  • BSD / OSX: sysctl variables kern.maxfiles and kern.maxfilesperproc, reaching these limits results in a "too many open files" error.

Examples

  • Basic example (use default options):
    watcher
    
  • Intermediate example:
    watcher --delay 1s
    
  • Advanced example:
    watcher -x 'go run .' --dir '~/Projects/watcher' --hidden false -l 50000
    

Documentation

Overview

Watcher is a command line tool that watches the files in the current directory and when any of the files change, it runs the specified command

Directories

Path Synopsis
Package watcher provides functions to watch files in a particular directory and run given functions when the files change
Package watcher provides functions to watch files in a particular directory and run given functions when the files change
cmd

Jump to

Keyboard shortcuts

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