feat: make --all configurable globally (#651)

* 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 <github@skatkov.com>
Co-authored-by: bashbunni <bunni@bashbunni.dev>
This commit is contained in:
Stanislav (Stas) Katkov 2024-10-01 19:23:20 +02:00 committed by GitHub
commit f1b565125f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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{

View file

@ -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
@ -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)
}