fix: allow config file to load showLineNumbers #653
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
showLineNumbers
config option tobe loaded from the config file
showLineNumbers
keywithin the config, and while there was support added for configuring
the
showLineNumbers
flag, it couldn't be read from the config file,since the
validateOptions
method would not retrieve the key fromthe config file
showLineNumbers
keyfrom the config file, and use it as needed
both the keys
Testing Notes
Ran
and for testing purposes to see if the config option was being read added in
func validateOptions(cmd *cobra.Command) error { // grab config values from Viper width = viper.GetUint("width") mouse = viper.GetBool("mouse") pager = viper.GetBool("pager") showAllFiles = viper.GetBool("all") preserveNewLines = viper.GetBool("preserveNewLines") + panic(fmt.Sprintf("preserveNewLines: %v, showLineNumbers: %v", preserveNewLines, showLineNumbers))
to showcase the configurations are being read
Previously:
When
preserveNewLines: true
andshowLineNumbers: true
within the config, the panic output shows thatpreserveNewLines
is being recognized, butshowLineNumbers
is not being recognized, which is unexpectedWhen
./glow -l
is used, the panic output shows that thepreserveNewLines
is being recognized, andshowLineNumbers
is being recognized which is expectedAfter:
When
preserveNewLines: true
andshowLineNumbers: true
within the config, the panic output shows thatpreserveNewLines
is being recognized andshowLineNumbers
is being recognized, which is expectedWhen
preserveNewLines: true
andshowLineNumbers: false
within the config, the panic output shows thatpreserveNewLines
is being recognized andshowLineNumbers
is being recognized, which is expectedRemoved the
panic
line used for testing purposes, rango build; ./glow
then navigated to the README.md to show that the line numbers are being shown, since the config hasshowLineNumbers: true
Other Notes
Related to #652