Add comprehensive documentation to shared functions

- Add detailed docstring to setupFormatFlag explaining parameters and usage
- Add detailed docstring to setupTestCommand explaining return values
- Use constant.DefaultConversion instead of hard-coded constant.WebP for better maintainability
- Clarify when bindViper should be true vs false

Co-authored-by: Belphemur <197810+Belphemur@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-10 20:27:28 +00:00
parent c5de49a310
commit 3a2fb2a97e
2 changed files with 16 additions and 5 deletions

View File

@@ -9,8 +9,14 @@ import (
"github.com/thediveo/enumflag/v2"
)
// setupFormatFlag sets up the format flag for a command
// If bindViper is true, it will also bind the flag to viper
// setupFormatFlag sets up the format flag for a command.
//
// Parameters:
// - cmd: The Cobra command to add the format flag to
// - converterType: Pointer to the ConversionFormat variable that will store the flag value
// - bindViper: If true, binds the flag to viper for configuration file support.
// Set to true for commands that use viper for configuration (e.g., watch command),
// and false for commands that don't (e.g., optimize command).
func setupFormatFlag(cmd *cobra.Command, converterType *constant.ConversionFormat, bindViper bool) {
formatFlag := enumflag.New(converterType, "format", constant.CommandValue, enumflag.EnumCaseInsensitive)
_ = formatFlag.RegisterCompletion(cmd, "format", constant.HelpText)