From e669bc059a626d9dabae256d7d67bb22700806e4 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Fri, 5 Jul 2024 09:25:32 +0200 Subject: [PATCH] Add installation and usage instructions to README --- README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/README.md b/README.md index 31887d1..6526194 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,71 @@ *A code formatter with rules set in stone.* +## Installation + +```julia +using Pkg +Pkg.add("Runic") +``` + +## Usage + +The main interface to Runic is the command line interface (CLI) through the `main` function +invoked with the `-m` flag. See the output of `julia -m Runic --help` for details: + +> [!NOTE] +> The `-m` command line flag is only available in Julia 1.12 and later. In earlier versions +> you have to invoke the `main` function explicitly, for example: +> ```sh +> julia -e 'using Runic; exit(Runic.main(ARGS))' -- +> ``` + +```sh +$ julia-master -m Runic --help +NAME + Runic.main - format Julia source code + +SYNOPSIS + julia -m Runic [] ... + +DESCRIPTION + `Runic.main` (typically invoked as `julia -m Runic`) formats Julia source + code using the Runic.jl formatter. + +OPTIONS + ... + Input path(s) (files and/or directories) to process. For directories, + all files (recursively) with the '*.jl' suffix are used as input files. + If path is `-` input is read from stdin. + + -c, --check + Do not write output and exit with a non-zero code if the input is not + formatted correctly. + + -d, --diff + Print the diff between the input and formatted output to stderr. + Requires `git` or `diff` to be installed. + + --fail-fast + Exit immediately after the first error. Only applicable when formatting + multiple files in the same invocation. + + --help + Print this message. + + -i, --inplace + Edit files in place. This option is required when passing multiple input + paths. + + -o, --output + Output file to write formatted code to. If the specified file is `-` + output is written to stdout. This option can not be used together with + multiple input paths. +``` + +In addition to the CLI there is also the two function `Runic.format_file` and +`Runic.format_string`. See their respective docstrings for details. + ## Formatting specification This is a list of the rules and formatting transformations performed by Runic: