Giter Site home page Giter Site logo

wtc's Introduction

WTC

Actions Status Go Report Card License

WTC is a simple utility you can use to watch files and execute commands.

Install

From master branch
$ go get -u github.com/rafaelsq/wtc

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/

Compile from source

Before you begin, ensure you have installed the latest version of Go. See the Go documentation for details.

$ go get -u github.com/rafaelsq/wtc

Usage

$ wtc --help
USAGE:
wtc [[flags] [regex command]]
        ex.: wtc
            // will read [.]wtc.y[a]ml
        ex.: wtc "_test\.go$" "go test -cover {PKG}"

wtc [flags]] [rule-name]
        ex.: wtc -t rule-name
             wtc --no-trace "rule ruleb"
FLAGS:
  -debounce int
        global debounce (default 300)
  -f string
        wtc config file (default try to find [.]wtc.y[a]ml)
  -ignore string
        regex
  -no-trace
        disable messages.
  -t string
        trig one or more rules by name
                ex.: 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:

no_trace: false
debounce: 300  # if rule has no debounce, this will be used instead
ignore: \.git/
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
  - name: BASE_FILE
    value: ./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

export PORT=3000

# replace from environment
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

debounce: 100
ignore: "\\.git/"
trig: install
rules:
  - name: install
    match: "\\.go$"
    command: "go install"

wtc's People

Contributors

bethanyj28 avatar dgupta04 avatar gabrielsimoes avatar lavarini avatar marco-silveira avatar rafaelsq avatar rodrigo-brito avatar scottydocs avatar tomerpacific avatar veridiem avatar vinicio avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.