Skip to content

Commit 43c2071

Browse files
committed
fix(cli): restore PRJ_ROOT env var
PRJ_ROOT is coming from the https://github.com/numtide/prj-spec and was used in treefmt 1.x Fixes #353
1 parent debc3e4 commit 43c2071

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

cli/cli.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Format struct {
2323
ConfigFile string `type:"existingfile" help:"Load the config file from the given path (defaults to searching upwards for treefmt.toml)."`
2424
FailOnChange bool `help:"Exit with error if any changes were made. Useful for CI."`
2525
Formatters []string `short:"f" help:"Specify formatters to apply. Defaults to all formatters."`
26-
TreeRoot string `type:"existingdir" xor:"tree-root" help:"The root directory from which treefmt will start walking the filesystem (defaults to the directory containing the config file)."`
26+
TreeRoot string `type:"existingdir" xor:"tree-root" env:"PRJ_ROOT" help:"The root directory from which treefmt will start walking the filesystem (defaults to the directory containing the config file)."`
2727
TreeRootFile string `type:"string" xor:"tree-root" help:"File to search for to find the project root (if --tree-root is not passed)."`
2828
Walk walk.Type `enum:"auto,git,filesystem" default:"auto" help:"The method used to traverse the files within --tree-root. Currently supports 'auto', 'git' or 'filesystem'."`
2929
Verbosity int `name:"verbose" short:"v" type:"counter" default:"0" env:"LOG_LEVEL" help:"Set the verbosity of logs e.g. -vv."`

docs/usage.md

+18-16
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,24 @@ Arguments:
1313
[<paths> ...] Paths to format. Defaults to formatting the whole tree.
1414
1515
Flags:
16-
-h, --help Show context-sensitive help.
17-
--allow-missing-formatter Do not exit with error if a configured formatter is missing.
18-
-C, --working-directory="." Run as if treefmt was started in the specified working directory instead of the current working directory.
19-
--no-cache Ignore the evaluation cache entirely. Useful for CI.
20-
-c, --clear-cache Reset the evaluation cache. Use in case the cache is not precise enough.
21-
--config-file="./treefmt.toml" The config file to use.
22-
--fail-on-change Exit with error if any changes were made. Useful for CI.
23-
--formatters=FORMATTERS,... Specify formatters to apply. Defaults to all formatters.
24-
--tree-root="." The root directory from which treefmt will start walking the filesystem.
25-
--walk="auto" The method used to traverse the files within --tree-root. Currently supports 'auto', 'git' or 'filesystem'.
26-
-v, --verbose Set the verbosity of logs e.g. -vv ($LOG_LEVEL).
27-
-V, --version Print version.
28-
-i, --init Create a new treefmt.toml.
29-
-u, --on-unmatched=warn Log paths that did not match any formatters at the specified log level, with fatal exiting the process with an error. Possible values are <debug|info|warn|error|fatal>.
30-
--stdin Format the context passed in via stdin.
31-
--cpu-profile=STRING The file into which a cpu profile will be written.
16+
-h, --help Show context-sensitive help.
17+
--allow-missing-formatter Do not exit with error if a configured formatter is missing.
18+
-C, --working-directory="." Run as if treefmt was started in the specified working directory instead of the current working directory.
19+
--no-cache Ignore the evaluation cache entirely. Useful for CI.
20+
-c, --clear-cache Reset the evaluation cache. Use in case the cache is not precise enough.
21+
--config-file=STRING Load the config file from the given path (defaults to searching upwards for treefmt.toml).
22+
--fail-on-change Exit with error if any changes were made. Useful for CI.
23+
-f, --formatters=FORMATTERS,... Specify formatters to apply. Defaults to all formatters.
24+
--tree-root=STRING The root directory from which treefmt will start walking the filesystem (defaults to the directory containing the config file) ($PRJ_ROOT).
25+
--tree-root-file=STRING File to search for to find the project root (if --tree-root is not passed).
26+
--walk="auto" The method used to traverse the files within --tree-root. Currently supports 'auto', 'git' or 'filesystem'.
27+
-v, --verbose Set the verbosity of logs e.g. -vv ($LOG_LEVEL).
28+
-V, --version Print version.
29+
-i, --init Create a new treefmt.toml.
30+
-u, --on-unmatched=warn Log paths that did not match any formatters at the specified log level, with fatal exiting the process with an error. Possible values are
31+
<debug|info|warn|error|fatal>.
32+
--stdin Format the context passed in via stdin.
33+
--cpu-profile=STRING The file into which a cpu profile will be written.
3234
```
3335

3436
## Arguments

0 commit comments

Comments
 (0)