Skip to content

Commit

Permalink
long time no see
Browse files Browse the repository at this point in the history
- Switched to FgBlue for headline color
- Skip default value if it is empty
- Added go.mod
- Added gitignore
  • Loading branch information
Paul Stølen committed Sep 22, 2021
1 parent b6d51d8 commit 42a95b5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/paul-at-start/simple-help

go 1.17

require github.com/fatih/color v1.13.0

require (
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
)
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
8 changes: 6 additions & 2 deletions simplehelp.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (h *SimpleHelp) Help() {

h.helpFormatString = h.makeHelpFormatStr()

grebo := color.New(color.FgGreen, color.Bold)
grebo := color.New(color.FgBlue, color.Bold)
printSection(h.ProgramTitle, h.ProgramDescription, grebo)

for _, section := range h.helpSections {
Expand All @@ -39,7 +39,11 @@ func (h *SimpleHelp) Help() {
grebo.Print("\nFlags:\n")
// print usage for all flags
flag.CommandLine.VisitAll(func(fl *flag.Flag) {
fmt.Printf(" --%s%s (Default: %s)\n", h.flagIndentation(fl.Name), fl.Usage, fl.DefValue)
var defaultString string
if fl.DefValue != "" {
defaultString = fmt.Sprintf("(Default: %s)", fl.DefValue)
}
fmt.Printf(" --%s%s %s\n", h.flagIndentation(fl.Name), fl.Usage, defaultString)
})

fmt.Print("\n")
Expand Down

0 comments on commit 42a95b5

Please sign in to comment.