just/README.md

63 lines
1.7 KiB
Markdown
Raw Normal View History

2016-10-30 19:15:43 -07:00
just
====
2016-09-27 22:49:17 -07:00
2016-10-30 22:47:29 -07:00
[![crates.io version](https://img.shields.io/crates/v/just.svg)](https://crates.io/crates/just)
2016-10-30 22:44:14 -07:00
2016-10-31 19:11:27 -07:00
`just` is a handy way to save and run commands.
Commands are stored in a file called `justfile` with a syntax inspired by `make`:
```make
# test everything. must build first
test-all: build
test --all
# run a specific test by passing it as an argument: `just test server-test`
test TEST: build
test --test {{TEST}}
# build the binary
build:
cc *.c -o main
version = "0.2.0"
tardir = "awesomesauce-" + version
tarball = tardir + ".tar.gz"
build-tarball:
rm -f {{tarball}}
mkdir {{tardir}}
cp README.md *.c {{tardir}}
tar zcvf {{tarball}} {{tardir}}
rm -rf {{tardir}}
publish: test build-tarball
scp {{tarball}} me@server.com:release/
# recipes can be written in any language
serve-docs:
#!/usr/bin/env python3
import os, http.server, socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
os.chdir('docs')
httpd = socketserver.TCPServer(("", PORT), Handler)
print("serving at port", PORT)
httpd.serve_forever()
```
`just` avoids `make`'s idiosyncrasies and produces excellent error messages, so debugging a `justfile` is easier and less suprising than debugging a makefile.
2016-09-27 22:49:17 -07:00
2016-09-28 21:58:06 -07:00
getting started
---------------
2016-10-31 19:11:27 -07:00
`just` should run on any system with a reasonable `sh`, and can be installed with `cargo`, the [rust language](https://www.rust-lang.org) package manager:
2016-09-28 21:58:06 -07:00
1. Get rust and cargo from [rustup.rs](https://www.rustup.rs)
2016-10-30 19:15:43 -07:00
2. Run `cargo install just`
2016-09-28 21:58:06 -07:00
3. Add `~/.cargo/bin` to your PATH
2016-10-31 19:11:27 -07:00
Then, create a file called `justfile` in the root of your project and start adding recipes to it.
2016-09-28 21:58:06 -07:00
2016-10-31 19:11:27 -07:00
Optionally, you can `alias j=just` for lighting fast command running.