1
1
mirror of https://github.com/casey/just.git synced 2024-11-22 18:34:06 +03:00

Use console codeblocks in readme (#2388)

This commit is contained in:
Casey Rodarmor 2024-09-22 23:03:26 +09:00 committed by GitHub
parent dffca62e8f
commit dc89b746f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

170
README.md
View File

@ -35,7 +35,7 @@ inspired by `make`:
You can then run them with `just RECIPE`: You can then run them with `just RECIPE`:
```sh ```console
$ just test-all $ just test-all
cc *.c -o main cc *.c -o main
./test --all ./test --all
@ -353,13 +353,13 @@ You can use the following command on Linux, MacOS, or Windows to download the
latest release, just replace `DEST` with the directory where you'd like to put latest release, just replace `DEST` with the directory where you'd like to put
`just`: `just`:
```sh ```console
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to DEST curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to DEST
``` ```
For example, to install `just` to `~/bin`: For example, to install `just` to `~/bin`:
```sh ```console
# create ~/bin # create ~/bin
mkdir -p ~/bin mkdir -p ~/bin
@ -471,7 +471,7 @@ call plug#end()
Or with Vim's built-in package support: Or with Vim's built-in package support:
```sh ```console
mkdir -p ~/.vim/pack/vendor/start mkdir -p ~/.vim/pack/vendor/start
cd ~/.vim/pack/vendor/start cd ~/.vim/pack/vendor/start
git clone https://github.com/NoahTheDuke/vim-just.git git clone https://github.com/NoahTheDuke/vim-just.git
@ -593,7 +593,7 @@ name `.justfile`, in case you'd like to hide a `justfile`.
Running `just` with no arguments runs the first recipe in the `justfile`: Running `just` with no arguments runs the first recipe in the `justfile`:
```sh ```console
$ just $ just
echo 'This is a recipe!' echo 'This is a recipe!'
This is a recipe! This is a recipe!
@ -601,7 +601,7 @@ This is a recipe!
One or more arguments specify the recipe(s) to run: One or more arguments specify the recipe(s) to run:
```sh ```console
$ just another-recipe $ just another-recipe
This is another recipe. This is another recipe.
``` ```
@ -634,7 +634,7 @@ sloc:
@echo "`wc -l *.c` lines of code" @echo "`wc -l *.c` lines of code"
``` ```
```sh ```console
$ just test $ just test
cc main.c foo.c bar.c -o main cc main.c foo.c bar.c -o main
./test ./test
@ -644,7 +644,7 @@ testing… all tests passed!
Recipes without dependencies will run in the order they're given on the command Recipes without dependencies will run in the order they're given on the command
line: line:
```sh ```console
$ just build sloc $ just build sloc
cc main.c foo.c bar.c -o main cc main.c foo.c bar.c -o main
1337 lines of code 1337 lines of code
@ -653,7 +653,7 @@ cc main.c foo.c bar.c -o main
Dependencies will always run first, even if they are passed after a recipe that Dependencies will always run first, even if they are passed after a recipe that
depends on them: depends on them:
```sh ```console
$ just test build $ just test build
cc main.c foo.c bar.c -o main cc main.c foo.c bar.c -o main
./test ./test
@ -708,7 +708,7 @@ default:
Recipes can be listed in alphabetical order with `just --list`: Recipes can be listed in alphabetical order with `just --list`:
```sh ```console
$ just --list $ just --list
Available recipes: Available recipes:
build build
@ -737,7 +737,7 @@ Available recipes:
`just --summary` is more concise: `just --summary` is more concise:
```sh ```console
$ just --summary $ just --summary
build test deploy lint build test deploy lint
``` ```
@ -752,14 +752,14 @@ build:
echo 'Building!' echo 'Building!'
``` ```
```sh ```console
$ just --list --unsorted $ just --list --unsorted
Available recipes: Available recipes:
test test
build build
``` ```
```sh ```console
$ just --summary --unsorted $ just --summary --unsorted
test build test build
``` ```
@ -781,7 +781,7 @@ error.
The heading text can be customized with `--list-heading`: The heading text can be customized with `--list-heading`:
```sh ```console
$ just --list --list-heading $'Cool stuff…\n' $ just --list --list-heading $'Cool stuff…\n'
Cool stuff… Cool stuff…
test test
@ -790,7 +790,7 @@ Cool stuff…
And the indentation can be customized with `--list-prefix`: And the indentation can be customized with `--list-prefix`:
```sh ```console
$ just --list --list-prefix ···· $ just --list --list-prefix ····
Available recipes: Available recipes:
····test ····test
@ -801,7 +801,7 @@ The argument to `--list-heading` replaces both the heading and the newline
following it, so it should contain a newline if non-empty. It works this way so following it, so it should contain a newline if non-empty. It works this way so
you can suppress the heading line entirely by passing the empty string: you can suppress the heading line entirely by passing the empty string:
```sh ```console
$ just --list --list-heading '' $ just --list --list-heading ''
test test
build build
@ -819,7 +819,7 @@ serve:
python3 -m http.server -d out 8000 python3 -m http.server -d out 8000
``` ```
```sh ```console
$ just build serve $ just build serve
make web make web
python3 -m http.server -d out 8000 python3 -m http.server -d out 8000
@ -836,7 +836,7 @@ serve:
python3 -m http.server -d out 8000 python3 -m http.server -d out 8000
``` ```
```sh ```console
$ just build serve $ just build serve
make: *** No rule to make target `serve'. Stop. make: *** No rule to make target `serve'. Stop.
``` ```
@ -844,7 +844,7 @@ make: *** No rule to make target `serve'. Stop.
The `--one` flag can be used to restrict command-line invocations to a single The `--one` flag can be used to restrict command-line invocations to a single
recipe: recipe:
```sh ```console
$ just --one build serve $ just --one build serve
error: Expected 1 command-line recipe invocation but found 2. error: Expected 1 command-line recipe invocation but found 2.
``` ```
@ -866,7 +866,7 @@ directory set to directory in which `just` was invoked.
pwd pwd
``` ```
```sh ```console
$ cd subdir $ cd subdir
$ just foo $ just foo
/ /
@ -884,7 +884,7 @@ set working-directory := 'bar'
pwd pwd
``` ```
```sh ```console
$ pwd $ pwd
/home/bob /home/bob
$ just foo $ just foo
@ -902,7 +902,7 @@ build:
echo 'Building!' echo 'Building!'
``` ```
```sh ```console
$ just b $ just b
echo 'Building!' echo 'Building!'
Building! Building!
@ -973,7 +973,7 @@ set allow-duplicate-recipes
echo bar echo bar
``` ```
```sh ```console
$ just foo $ just foo
bar bar
``` ```
@ -994,7 +994,7 @@ a := "bar"
echo $a echo $a
``` ```
```sh ```console
$ just foo $ just foo
bar bar
``` ```
@ -1029,7 +1029,7 @@ must be accessed using `$VARIABLE_NAME` in recipes and backticks.
For example, if your `.env` file contains: For example, if your `.env` file contains:
```sh ```console
# a comment, will be ignored # a comment, will be ignored
DATABASE_ADDRESS=localhost:6379 DATABASE_ADDRESS=localhost:6379
SERVER_PORT=1337 SERVER_PORT=1337
@ -1047,7 +1047,7 @@ serve:
`just serve` will output: `just serve` will output:
```sh ```console
$ just serve $ just serve
Starting server with database localhost:6379 on port 1337… Starting server with database localhost:6379 on port 1337…
./server --database $DATABASE_ADDRESS --port $SERVER_PORT ./server --database $DATABASE_ADDRESS --port $SERVER_PORT
@ -1068,7 +1068,7 @@ a := "hello"
echo $b echo $b
``` ```
```sh ```console
$ just foo goodbye $ just foo goodbye
hello hello
goodbye goodbye
@ -1092,7 +1092,7 @@ set positional-arguments
Will produce the following output: Will produce the following output:
```sh ```console
$ just foo hello $ just foo hello
foo foo
hello hello
@ -1116,7 +1116,7 @@ set positional-arguments
Running it with _two_ arguments: Running it with _two_ arguments:
```sh ```console
$ just test foo "bar baz" $ just test foo "bar baz"
- foo - foo
- bar baz - bar baz
@ -1241,7 +1241,7 @@ test:
./bin/test ./bin/test
``` ```
```sh ```console
$ just --list $ just --list
Available recipes: Available recipes:
build # build stuff build # build stuff
@ -1262,7 +1262,7 @@ test:
./bin/test ./bin/test
``` ```
```sh ```console
$ just --list $ just --list
Available recipes: Available recipes:
build # Build stuff build # Build stuff
@ -1371,7 +1371,7 @@ tab := "\t"
unicode-codepoint := "\u{1F916}" unicode-codepoint := "\u{1F916}"
``` ```
```sh ```console
$ just --evaluate $ just --evaluate
"arriage-return := " "arriage-return := "
double-quote := """ double-quote := """
@ -1404,7 +1404,7 @@ Single-quoted strings do not recognize escape sequences:
escapes := '\t\n\r\"\\' escapes := '\t\n\r\"\\'
``` ```
```sh ```console
$ just --evaluate $ just --evaluate
escapes := "\t\n\r\"\\" escapes := "\t\n\r\"\\"
``` ```
@ -1466,7 +1466,7 @@ foo:
echo 'Done!' echo 'Done!'
``` ```
```sh ```console
$ just foo $ just foo
cat foo cat foo
cat: foo: No such file or directory cat: foo: No such file or directory
@ -1504,7 +1504,7 @@ system-info:
@echo "This is an {{arch()}} machine". @echo "This is an {{arch()}} machine".
``` ```
```sh ```console
$ just system-info $ just system-info
This is an x86_64 machine This is an x86_64 machine
``` ```
@ -1567,7 +1567,7 @@ test:
echo "{{home_dir}}" echo "{{home_dir}}"
``` ```
```sh ```console
$ just $ just
/home/user1 /home/user1
``` ```
@ -1650,7 +1650,7 @@ executable:
@echo The executable is at: {{just_executable()}} @echo The executable is at: {{just_executable()}}
``` ```
```sh ```console
$ just $ just
The executable is at: /bin/just The executable is at: /bin/just
``` ```
@ -1666,7 +1666,7 @@ pid:
@echo The process ID is: {{ just_pid() }} @echo The process ID is: {{ just_pid() }}
``` ```
```sh ```console
$ just $ just
The process ID is: 420 The process ID is: 420
``` ```
@ -1827,7 +1827,7 @@ A number of constants are predefined:
echo {{HEX}} echo {{HEX}}
``` ```
```sh ```console
$ just foo $ just foo
0123456789abcdef 0123456789abcdef
``` ```
@ -2050,7 +2050,7 @@ bar:
@echo "{{foo}}" @echo "{{foo}}"
``` ```
```sh ```console
$ just bar $ just bar
Good! Good!
``` ```
@ -2064,7 +2064,7 @@ bar:
@echo {{foo}} @echo {{foo}}
``` ```
```sh ```console
$ just bar $ just bar
xyz xyz
``` ```
@ -2078,7 +2078,7 @@ bar:
@echo {{foo}} @echo {{foo}}
``` ```
```sh ```console
$ just bar $ just bar
match match
``` ```
@ -2122,7 +2122,7 @@ bar:
@echo {{foo}} @echo {{foo}}
``` ```
```sh ```console
$ just bar $ just bar
abc abc
``` ```
@ -2163,7 +2163,7 @@ build:
./build {{os}} ./build {{os}}
``` ```
```sh ```console
$ just $ just
./build linux ./build linux
./test --test linux ./test --test linux
@ -2171,7 +2171,7 @@ $ just
Any number of arguments of the form `NAME=VALUE` can be passed before recipes: Any number of arguments of the form `NAME=VALUE` can be passed before recipes:
```sh ```console
$ just os=plan9 $ just os=plan9
./build plan9 ./build plan9
./test --test plan9 ./test --test plan9
@ -2179,7 +2179,7 @@ $ just os=plan9
Or you can use the `--set` flag: Or you can use the `--set` flag:
```sh ```console
$ just --set os bsd $ just --set os bsd
./build bsd ./build bsd
./test --test bsd ./test --test bsd
@ -2252,7 +2252,7 @@ print_home_folder:
echo "HOME is: '${HOME}'" echo "HOME is: '${HOME}'"
``` ```
```sh ```console
$ just $ just
HOME is '/home/myuser' HOME is '/home/myuser'
``` ```
@ -2276,7 +2276,7 @@ build target:
To pass arguments on the command line, put them after the recipe name: To pass arguments on the command line, put them after the recipe name:
```sh ```console
$ just build my-awesome-project $ just build my-awesome-project
Building my-awesome-project… Building my-awesome-project…
cd my-awesome-project && make cd my-awesome-project && make
@ -2328,7 +2328,7 @@ test target tests=default:
Parameters with default values may be omitted: Parameters with default values may be omitted:
```sh ```console
$ just test server $ just test server
Testing server:all… Testing server:all…
./test --tests all server ./test --tests all server
@ -2336,7 +2336,7 @@ Testing server:all…
Or supplied: Or supplied:
```sh ```console
$ just test server unit $ just test server unit
Testing server:unit… Testing server:unit…
./test --tests unit server ./test --tests unit server
@ -2363,7 +2363,7 @@ backup +FILES:
Variadic parameters prefixed with `+` accept _one or more_ arguments and expand Variadic parameters prefixed with `+` accept _one or more_ arguments and expand
to a string containing those arguments separated by spaces: to a string containing those arguments separated by spaces:
```sh ```console
$ just backup FAQ.md GRAMMAR.md $ just backup FAQ.md GRAMMAR.md
scp FAQ.md GRAMMAR.md me@server.com: scp FAQ.md GRAMMAR.md me@server.com:
FAQ.md 100% 1831 1.8KB/s 00:00 FAQ.md 100% 1831 1.8KB/s 00:00
@ -2397,7 +2397,7 @@ search QUERY:
And you type: And you type:
```sh ```console
$ just search "cat toupee" $ just search "cat toupee"
``` ```
@ -2524,7 +2524,7 @@ d:
…running _b_ prints: …running _b_ prints:
```sh ```console
$ just b $ just b
echo 'A!' echo 'A!'
A! A!
@ -2557,7 +2557,7 @@ c:
…running _b_ prints: …running _b_ prints:
```sh ```console
$ just b $ just b
echo 'A!' echo 'A!'
A! A!
@ -2609,7 +2609,7 @@ ruby:
puts "Hello from ruby!" puts "Hello from ruby!"
``` ```
```sh ```console
$ just polyglot $ just polyglot
Hello from python! Hello from python!
Greetings from JavaScript! Greetings from JavaScript!
@ -2857,7 +2857,7 @@ conditional:
The extra leading whitespace before the second line of the `conditional` recipe The extra leading whitespace before the second line of the `conditional` recipe
will produce a parse error: will produce a parse error:
```sh ```console
$ just conditional $ just conditional
error: Recipe line has extra leading whitespace error: Recipe line has extra leading whitespace
| |
@ -3000,7 +3000,7 @@ recipe:
`just` supports a number of useful command line options for listing, dumping, `just` supports a number of useful command line options for listing, dumping,
and debugging recipes and variables: and debugging recipes and variables:
```sh ```console
$ just --list $ just --list
Available recipes: Available recipes:
js js
@ -3018,14 +3018,14 @@ polyglot: python js perl sh ruby
Some command-line options can be set with environment variables. For example: Some command-line options can be set with environment variables. For example:
```sh ```console
$ export JUST_UNSTABLE=1 $ export JUST_UNSTABLE=1
$ just $ just
``` ```
Is equivalent to: Is equivalent to:
```sh ```console
$ just --unstable $ just --unstable
``` ```
@ -3044,7 +3044,7 @@ _test-helper:
./bin/super-secret-test-helper-stuff ./bin/super-secret-test-helper-stuff
``` ```
```sh ```console
$ just --list $ just --list
Available recipes: Available recipes:
test test
@ -3052,7 +3052,7 @@ Available recipes:
And from `just --summary`: And from `just --summary`:
```sh ```console
$ just --summary $ just --summary
test test
``` ```
@ -3070,7 +3070,7 @@ alias b := bar
bar: bar:
``` ```
```sh ```console
$ just --list $ just --list
Available recipes: Available recipes:
bar bar
@ -3093,7 +3093,7 @@ line:
Now only the lines starting with `@` will be echoed: Now only the lines starting with `@` will be echoed:
```sh ```console
$ just quiet $ just quiet
hello hello
goodbye goodbye
@ -3133,7 +3133,7 @@ foo:
echo 'Foo!' echo 'Foo!'
``` ```
```sh ```console
$ just foo $ just foo
Foo! Foo!
``` ```
@ -3147,7 +3147,7 @@ executing it:
echo 'Bar!' echo 'Bar!'
``` ```
```sh ```console
$ just bar $ just bar
#!/usr/bin/env bash #!/usr/bin/env bash
echo 'Bar!' echo 'Bar!'
@ -3163,7 +3163,7 @@ git *args:
@git {{args}} @git {{args}}
``` ```
```sh ```console
$ just git status $ just git status
fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git
error: Recipe `git` failed on line 2 with exit code 128 error: Recipe `git` failed on line 2 with exit code 128
@ -3178,7 +3178,7 @@ git *args:
@git {{args}} @git {{args}}
``` ```
```sh ```console
$ just git status $ just git status
fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git
``` ```
@ -3232,7 +3232,7 @@ For example, if you are in a directory which contains a subdirectory named
`foo`, which contains a `justfile` with the recipe `build`, which is also the `foo`, which contains a `justfile` with the recipe `build`, which is also the
default recipe, the following are all equivalent: default recipe, the following are all equivalent:
```sh ```console
$ (cd foo && just build) $ (cd foo && just build)
$ just foo/build $ just foo/build
$ just foo/ $ just foo/
@ -3241,7 +3241,7 @@ $ just foo/
Additional recipes after the first are sought in the same `justfile`. For Additional recipes after the first are sought in the same `justfile`. For
example, the following are both equivalent: example, the following are both equivalent:
```sh ```console
$ just foo/a b $ just foo/a b
$ (cd foo && just a b) $ (cd foo && just a b)
``` ```
@ -3270,7 +3270,7 @@ b:
`foo/bar.just` will be included in `justfile` and recipe `b` will be defined: `foo/bar.just` will be included in `justfile` and recipe `b` will be defined:
```sh ```console
$ just b $ just b
B B
$ just a $ just a
@ -3330,14 +3330,14 @@ uses its own settings.
Recipes in submodules can be invoked as subcommands: Recipes in submodules can be invoked as subcommands:
```sh ```console
$ just bar b $ just bar b
B B
``` ```
Or with path syntax: Or with path syntax:
```sh ```console
$ just bar::b $ just bar::b
B B
``` ```
@ -3395,7 +3395,7 @@ output<sup>1.30.0</sup>:
mod foo mod foo
``` ```
```sh ```console
$ just --list $ just --list
Available recipes: Available recipes:
foo ... # foo is a great module! foo ... # foo is a great module!
@ -3416,7 +3416,7 @@ used to keep a `justfile` hidden.
By adding a shebang line to the top of a `justfile` and making it executable, By adding a shebang line to the top of a `justfile` and making it executable,
`just` can be used as an interpreter for scripts: `just` can be used as an interpreter for scripts:
```sh ```console
$ cat > script <<EOF $ cat > script <<EOF
#!/usr/bin/env just --justfile #!/usr/bin/env just --justfile
@ -3456,7 +3456,7 @@ newlines.
You can overwrite the current justfile with a canonically-formatted version You can overwrite the current justfile with a canonically-formatted version
using the currently-unstable `--fmt` flag: using the currently-unstable `--fmt` flag:
```sh ```console
$ cat justfile $ cat justfile
# A lot of blank lines # A lot of blank lines
@ -3481,7 +3481,7 @@ formatted correctly, and will exit with 1 and print a diff if it is not.
You can use the `--dump` command to output a formatted version of the You can use the `--dump` command to output a formatted version of the
`justfile` to stdout: `justfile` to stdout:
```sh ```console
$ just --dump > formatted-justfile $ just --dump > formatted-justfile
``` ```
@ -3510,7 +3510,7 @@ bar:
echo bar echo bar
``` ```
```sh ```console
$ just bar $ just bar
Trying ../justfile Trying ../justfile
echo bar echo bar
@ -3528,7 +3528,7 @@ foo argument:
The following command will create two files, `some` and `argument.txt`: The following command will create two files, `some` and `argument.txt`:
```sh ```console
$ just foo "some argument.txt" $ just foo "some argument.txt"
``` ```
@ -3663,7 +3663,7 @@ when files change.
To re-run the recipe `foo` when any file changes: To re-run the recipe `foo` when any file changes:
```sh ```console
watchexec just foo watchexec just foo
``` ```
@ -3692,7 +3692,7 @@ In `bash`, the aliased command may not keep the shell completion functionality
described in the next section. Add the following line to your `.bashrc` to use described in the next section. Add the following line to your `.bashrc` to use
the same completion function as `just` for your aliased command: the same completion function as `just` for your aliased command:
```sh ```console
complete -F _just -o bashdefault -o default j complete -F _just -o bashdefault -o default j
``` ```
@ -3704,7 +3704,7 @@ are available [release archives](https://github.com/casey/just/releases).
The `just` binary can also generate the same completion scripts at runtime The `just` binary can also generate the same completion scripts at runtime
using `just --completions SHELL`: using `just --completions SHELL`:
```sh ```console
$ just --completions zsh > just.zsh $ just --completions zsh > just.zsh
``` ```
@ -3784,7 +3784,7 @@ If you want to call the recipes in `~/.user.justfile` by name, and don't mind
creating an alias for every recipe, add the following to your shell's creating an alias for every recipe, add the following to your shell's
initialization script: initialization script:
```sh ```console
for recipe in `just --justfile ~/.user.justfile --summary`; do for recipe in `just --justfile ~/.user.justfile --summary`; do
alias $recipe="just --justfile ~/.user.justfile --working-directory . $recipe" alias $recipe="just --justfile ~/.user.justfile --working-directory . $recipe"
done done
@ -3801,7 +3801,7 @@ advance in `justfile` technology.
If you'd rather not create aliases for every recipe, you can create a single alias: If you'd rather not create aliases for every recipe, you can create a single alias:
```sh ```console
alias .j='just --justfile ~/.user.justfile --working-directory .' alias .j='just --justfile ~/.user.justfile --working-directory .'
``` ```
@ -3818,7 +3818,7 @@ You can customize the above aliases with additional options. For example, if
you'd prefer to have the recipes in your `justfile` run in your home directory, you'd prefer to have the recipes in your `justfile` run in your home directory,
instead of the current directory: instead of the current directory:
```sh ```console
alias .j='just --justfile ~/.user.justfile --working-directory ~' alias .j='just --justfile ~/.user.justfile --working-directory ~'
``` ```
@ -4048,7 +4048,7 @@ test:
`make` will refuse to run your tests: `make` will refuse to run your tests:
```sh ```console
$ make test $ make test
make: `test' is up to date. make: `test' is up to date.
``` ```