From de900ec2cdc00e0b4a0602fc6f1a88fd7fc2c5fd Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Fri, 4 Jul 2025 10:59:28 -0700 Subject: Flag placement --- hi.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'hi.go') diff --git a/hi.go b/hi.go index 7d3370a..2cb87d5 100644 --- a/hi.go +++ b/hi.go @@ -9,18 +9,6 @@ import ( "strings" ) -func init() { - highlightColor = red - flag.Var((*colorFlag)(&highlightColor), "c", fmt.Sprintf("highlight `color` %s", colorsChoices)) - background = defaultColor - flag.Var((*colorFlag)(&background), "bg", fmt.Sprintf("background `color` default|%s", colorsChoices)) -} - -var ( - highlightColor ansiColor - background ansiColor -) - //go:generate stringer -type=ansiColor -linecomment type ansiColor int @@ -87,6 +75,11 @@ func (c *colorFlag) String() string { return ansiColor(*c).String() } +var ( + highlightColor = red + background = defaultColor +) + func run() error { args := flag.Args() if len(args) == 0 { @@ -132,6 +125,8 @@ Examples: `) os.Exit(2) } + flag.Var((*colorFlag)(&highlightColor), "c", fmt.Sprintf("highlight `color` %s", colorsChoices)) + flag.Var((*colorFlag)(&background), "bg", fmt.Sprintf("background `color` default|%s", colorsChoices)) flag.Parse() if err := run(); err != nil { fmt.Fprintf(os.Stderr, "hi: %s\n", err) -- cgit v1.3.1