watchgod

command
v0.0.0-...-b60358c Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

README

watchgod

Installation

$ go install bloom.sh/stdx/tools/watchgod
# or
$ git clone https://bloom.sh/pingoo/pkg/stdx.git && cd golibs/tools/watchgod && go install

How to use

$ watchgod -build="go build" -command="./myprogram"

License

See License.txt

watchgod is a fork of https://github.com/githubnemo/CompileDaemon @ 02443802e48675a5457cc15bdee6145d3a56b800

Documentation

Overview

watchgod is a very simple compile daemon for Go. watchgod watches your .go files in a directory and invokes `go build` if a file changes. Examples In its simplest form, the defaults will do. With the current working directory set to the source directory you can simply…

$ watchgod

… and it will recompile your code whenever you save a source file. If you want it to also run your program each time it builds you might add…

$ watchgod -command="./MyProgram -my-options"

… and it will also keep a copy of your program running. Killing the old one and starting a new one each time you build. For advanced usage you can also supply the changed file to the command by doing…

$ watchgod -command="./MyProgram -my-options %[1]s"

…but note that this will not be set on the first start. You may find that you need to exclude some directories and files from monitoring, such as a .git repository or emacs temporary files…

$ watchgod -exclude-dir=.git -exclude=".#*"

If you want to monitor files other than .go and .c files you might…

$ watchgod -include=Makefile -include="*.less" -include="*.tmpl"

Options There are command line options.

FILE SELECTION
-directory=XXX    – Which directory to monitor for changes
-recursive=XXX    – Look into subdirectories
-exclude-dir=XXX  – Exclude directories matching glob pattern XXX
-exlude=XXX       – Exclude files whose basename matches glob pattern XXX
-include=XXX      – Include files whose basename matches glob pattern XXX
-pattern=XXX      – Include files whose path matches regexp XXX
MISC
-log-prefix       - Enable/disable stdout/stderr labelling for the child process
-graceful-kill    - On supported platforms, send the child process a SIGTERM to
                    allow it to exit gracefully if possible.
-graceful-timeout - Duration (in seconds) to wait for graceful kill to complete
-verbose          - Print information about watched directories.
ACTIONS
-build=CCC        – Execute CCC to rebuild when a file changes
-command=CCC      – Run command CCC after a successful build, stops previous command first

Jump to

Keyboard shortcuts

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