-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 'Feature parity with treefmt.rs' (#22) from feat/e…
…xplicit-paths-and-stdin into main Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/22 Reviewed-by: Jonas Chevalier <[email protected]>
- Loading branch information
Showing
27 changed files
with
450 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package build | ||
|
||
var ( | ||
Name = "treefmt" | ||
Version = "v0.0.1+dev" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,38 @@ | ||
package cli | ||
|
||
import ( | ||
"git.numtide.com/numtide/treefmt/internal/walk" | ||
"git.numtide.com/numtide/treefmt/walk" | ||
"github.com/alecthomas/kong" | ||
"github.com/charmbracelet/log" | ||
) | ||
|
||
var Cli = Options{} | ||
var Cli = Format{} | ||
|
||
type Options struct { | ||
AllowMissingFormatter bool `default:"false" help:"Do not exit with error if a configured formatter is missing."` | ||
WorkingDirectory kong.ChangeDirFlag `default:"." short:"C" help:"Run as if treefmt was started in the specified working directory instead of the current working directory."` | ||
ClearCache bool `short:"c" help:"Reset the evaluation cache. Use in case the cache is not precise enough."` | ||
type Format struct { | ||
AllowMissingFormatter bool `default:"false" help:"Do not exit with error if a configured formatter is missing"` | ||
WorkingDirectory kong.ChangeDirFlag `default:"." short:"C" help:"Run as if treefmt was started in the specified working directory instead of the current working directory"` | ||
NoCache bool `help:"Ignore the evaluation cache entirely. Useful for CI"` | ||
ClearCache bool `short:"c" help:"Reset the evaluation cache. Use in case the cache is not precise enough"` | ||
ConfigFile string `type:"existingfile" default:"./treefmt.toml"` | ||
FailOnChange bool `help:"Exit with error if any changes were made. Useful for CI."` | ||
Formatters []string `help:"Specify formatters to apply. Defaults to all formatters."` | ||
TreeRoot string `type:"existingdir" default:"."` | ||
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'."` | ||
Verbosity int `name:"verbose" short:"v" type:"counter" default:"0" env:"LOG_LEVEL" help:"Set the verbosity of logs e.g. -vv."` | ||
Version bool `name:"version" short:"V" help:"Print version"` | ||
|
||
Format Format `cmd:"" default:"."` | ||
Paths []string `name:"paths" arg:"" type:"path" optional:"" help:"Paths to format. Defaults to formatting the whole tree."` | ||
Stdin bool `help:"Format the context passed in via stdin"` | ||
} | ||
|
||
func (c *Options) Configure() { | ||
func (f *Format) Configure() { | ||
log.SetReportTimestamp(false) | ||
|
||
if c.Verbosity == 0 { | ||
if f.Verbosity == 0 { | ||
log.SetLevel(log.WarnLevel) | ||
} else if c.Verbosity == 1 { | ||
} else if f.Verbosity == 1 { | ||
log.SetLevel(log.InfoLevel) | ||
} else if c.Verbosity >= 2 { | ||
} else if f.Verbosity > 1 { | ||
log.SetLevel(log.DebugLevel) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.