Code Monkey home page Code Monkey logo

wu's Introduction

wu (呜~)

A minimal Watch Utility who can run and restart specified command in response to file changes automatically.

This utility is intended to provide a tiny tool to automate the Edit-Build-Run loop of development. Although it is quite similar to watch tasks of Grunt or Gulp, wu is designed to be just a single command with simplest interfaces to work with.

Install

To install wu from source code, you have to install Golang's tool chain first. Then run:

go get github.com/shanzi/wu
go install github.com/shanzi/wu

Precompiled version can be found here.

Usage

Run wu -h for help message:

Usage: wu [options] [command]
  -config string
        Config file (default ".wu.json")
  -dir string
        Directory to watch
  -pattern string
        Patterns to filter filenames
  -save
        Save options to conf

Examples

You just run you command with wu, wu will run your command at the start, try to terminate previous when new changes take place and then start running a new one. You can stop the process by sending a SIGINT signal (typically by CTRL-C):

wu sleep 10

Output:

Start watching...
- Running command: sleep 10
- Terminated.
File changed: /path/to/changed/file.txt
- Running command: sleep 10
- Done.
File changed: /path/to/changed/file.txt
- Running command: sleep 10
- Done.
^C
Shutting down...

Usually you can only run one command with wu, but it doesn't prevent you from running complex command with sh, bash or other shell command:

wu sh -c 'echo "START" && sleep 5 && echo "END"'

Output:

Start watching...
- Running command: sh -c echo "START" && sleep 5 && echo "END"
START
END
- Done.

You can specified a pattern to filter the files to watch. Multiple patterns should be seperated by spaces or commas:

wu -pattern="*.js, *.html"

Output (If no command specified, wu just log changed files):

Start watching...
File changed: /path/to/changed/file.js
File changed: /path/to/changed/file.html

One practical use case is to use wu with some light weight web frameworks, For example, you can start a server written in go by:

wu -pattern="*.go" go run main.go

wu will try to read config file under current directory at the start (default: .wu.json), you can user -config flag to specify the config file by hand. Use -save flag to save current options.

wu -pattern="*.go" -save go build
# A `.wu.json` has been created

wu # Running `wu` without any options, it will read from `.wu.json`

LICENSE

See LICENSE

wu's People

Contributors

shanzi avatar

Watchers

James Cloos 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.