Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make --all configurable globally #651

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading