Skip to content

Commit

Permalink
feat: make --all configurable globally (#651)
Browse files Browse the repository at this point in the history
* Make --all configurable globally

* docs: add all option to docs and default config

* refactor: tidy fields, set showAllFiles to true if unset

---------

Co-authored-by: Stanislav (Stas) Katkov <[email protected]>
Co-authored-by: bashbunni <[email protected]>
  • Loading branch information
3 people authored Oct 1, 2024
1 parent 67243bb commit f1b5651
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ mouse: true
pager: true
# at which column should we word wrap?
width: 80
# show all files, including hidden and ignored.
all: true
```
## Feedback
Expand Down
2 changes: 2 additions & 0 deletions config_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ mouse: false
pager: false
# word-wrap at width
width: 80
# show all files, including hidden and ignored.
all: true
`

var configCmd = &cobra.Command{
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func validateOptions(cmd *cobra.Command) error {
width = viper.GetUint("width")
mouse = viper.GetBool("mouse")
pager = viper.GetBool("pager")
showAllFiles = viper.GetBool("all")
preserveNewLines = viper.GetBool("preserveNewLines")

// validate the glamour style
Expand Down Expand Up @@ -373,10 +374,11 @@ func init() {
_ = viper.BindPFlag("mouse", rootCmd.Flags().Lookup("mouse"))
_ = viper.BindPFlag("preserveNewLines", rootCmd.Flags().Lookup("preserve-new-lines"))
_ = viper.BindPFlag("showLineNumbers", rootCmd.Flags().Lookup("line-numbers"))
_ = viper.BindPFlag("showAllFiles", rootCmd.Flags().Lookup("all"))
_ = viper.BindPFlag("all", rootCmd.Flags().Lookup("all"))

viper.SetDefault("style", styles.AutoStyle)
viper.SetDefault("width", 0)
viper.SetDefault("all", true)

rootCmd.AddCommand(configCmd, manCmd)
}
Expand Down

0 comments on commit f1b5651

Please sign in to comment.