Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rafaelsq/wtc
WTC is a simple utility you can use to watch files and execute commands.
https://github.com/rafaelsq/wtc
go golang hacktoberfest utility watch-files
Last synced: about 2 months ago
JSON representation
WTC is a simple utility you can use to watch files and execute commands.
- Host: GitHub
- URL: https://github.com/rafaelsq/wtc
- Owner: rafaelsq
- License: mit
- Created: 2019-10-08T14:25:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-03T21:07:26.000Z (about 1 year ago)
- Last Synced: 2024-08-03T23:29:07.036Z (5 months ago)
- Topics: go, golang, hacktoberfest, utility, watch-files
- Language: Go
- Homepage:
- Size: 666 KB
- Stars: 30
- Watchers: 3
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WTC
[![Actions Status](https://github.com/rafaelsq/wtc/workflows/tests/badge.svg)](https://github.com/rafaelsq/wtc/actions)
[![Go Report Card](https://goreportcard.com/badge/github.com/rafaelsq/wtc)](https://goreportcard.com/report/github.com/rafaelsq/wtc)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/rafaelsq/wtc/blob/master/LICENSE)WTC is a simple utility you can use to watch files and execute commands.
## Install
From master branch
`$ go install github.com/rafaelsq/wtc@latest`You can also install by release(linux64 only);
`$ curl -sfL --silent https://github.com/rafaelsq/wtc/releases/latest/download/wtc.linux64.tar.gz | tar -xzv && mv wtc $(go env GOPATH)/bin/`Or just head to the [releases page](https://github.com/rafaelsq/wtc/releases) and download the latest version for you platform.
## Compile from source
Before you begin, ensure you have installed the latest version of Go. See the [Go documentation](https://golang.org/doc/install) for details.
`$ go get -u github.com/rafaelsq/wtc`
## Usage
```
$ wtc --help
USAGE:
wtc [[flags] [regex command]]
e.g.: wtc
// will read [.]wtc.y[a]ml
e.g.: wtc -r -sfmt "_test\.go$" "go test -cover {PKG}"wtc [flags]] [rule-name]
e.g.: wtc -t rule-name
wtc --no-trace "rule ruleb"
wtc -arg-pkg any/path rule
wtc -arg-file path/to/file.ext rule
FLAGS:
-arg-file string
wtc -arg-file path/to/file rule-name
-arg-pkg string
wtc -arg-pkg path/to/folder rule-name
-debounce int
global debounce (default 300)
-f string
wtc config file (default try to find [.]wtc.y[a]ml)
-ignore string
regex
-ignore-rules string
ignore one or more rules (e.g.: -ignore-rules "ruleA,ruleB"
or export WTC_IGNORE_RULES=ruleA,ruleB)
-no-trace
disable messages.
-r run on start
-sfmt
simple format(stderr red)
-t string
trig one or more rules by name
e.g.: wtc -t ruleA
wtc -t "ruleA ruleB"
```## Usage with [.]wtc.y[a]ml
You can configure WTC by creating an YAML file with your own rules.
Example with all options:
```yaml
no_trace: false
debounce: 300 # if rule has no debounce, this will be used instead
ignore: \.git/
kill_signal: 2 # SIGINT (default: 9 SIGKILL)
kill_timeout: 3 # how many seconds we wait for the applicaton to exit before we send SIGKILL(9)
format:
time: "15:04:05" # golang format
ok: "\u001b[38;5;244m[{{.Time}}] \u001b[38;5;2m[{{.Title}}]\u001b[0m \u001b[38;5;238m{{.Message}}\u001b[0m\n"
fail: "\u001b[38;5;244m[{{.Time}}] \u001b[38;5;1m[{{.Title}}] \u001b[38;5;238m{{.Message}}\u001b[0m\n"
command_ok: "\u001b[38;5;240m[{{.Time}}] [{{.Title}}] \u001b[0m{{.Message}}\n"
command_err: "\u001b[38;5;240m[{{.Time}}] [{{.Title}}] \u001b[38;5;1m{{.Message}}\u001b[0m\n"
trig: [start, buildNRun] # will run start and after buildNRun
trig_async: # will run test and async concurrently
- test
- async
env:
- name: PORT
value: 2000
- type: file
name: ./base.env
rules:
- name: start
- name: buildNRun
match: \.go$
ignore: _test\.go$
command: go build
env:
- name: ENV
value: development
- name: %{BASE_FILE}% # replace from environment
type: file
trig:
- done build
- run
- test
- name: done build
- name: run
command: ./$(basename `pwd`)
- name: test
env:
- name: ENV
value: test
- name: %{BASE_FILE}%
type: file
match: _test\.go$
command: go test -cover {PKG}
- name: async
command: echo async
```Example base.env
```bash
export PORT=3000# will be replaced by the environment variable
ENVIRONMENT=%{ENV}%
```You can also trig a rule using `wtc -t`, example;
`wtc -t "start buildNRun"`
`wtc --no-trace buildNRun`## Dev
`$ make` will watch for changes and run `go install` or just run `$ go run main.go`
```yaml
debounce: 100
ignore: "\\.git/"
trig: install
rules:
- name: install
match: "\\.go$"
command: "go install"
```