mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-09 09:49:09 +02:00
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:
parent
67243bb6fb
commit
f1b565125f
3 changed files with 7 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
4
main.go
4
main.go
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue