Skip to content

Commit

Permalink
adjust help text
Browse files Browse the repository at this point in the history
  • Loading branch information
phm07 committed Jul 3, 2024
1 parent 0261566 commit 9b23dfc
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 93 deletions.
21 changes: 17 additions & 4 deletions internal/cmd/config/helptext/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ import (
//go:generate go run $GOFILE

func main() {
generateTable("preferences.txt", config.OptionFlagPreference, true)
generateTable("other.txt", config.OptionFlagPreference, false)
generateTable(
"preferences.txt",
config.OptionFlagPreference|config.OptionFlagHidden,
config.OptionFlagPreference,
table.Row{"sort.<resource>", "Default sorting for resource", "string list", "sort.<resource>", "HCLOUD_SORT_<RESOURCE>", ""},
)
generateTable("other.txt",
config.OptionFlagPreference|config.OptionFlagHidden,
0,
)
}

func generateTable(outFile string, filterFlag config.OptionFlag, hasFlag bool) {
func generateTable(outFile string, mask, filter config.OptionFlag, extraRows ...table.Row) {
f, err := os.OpenFile(outFile, os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
panic(err)
Expand All @@ -46,7 +54,7 @@ func generateTable(outFile string, filterFlag config.OptionFlag, hasFlag bool) {

var opts []config.IOption
for _, opt := range config.Options {
if opt.HasFlags(filterFlag) != hasFlag {
if opt.GetFlags()&mask != filter {
continue
}
opts = append(opts, opt)
Expand All @@ -61,6 +69,11 @@ func generateTable(outFile string, filterFlag config.OptionFlag, hasFlag bool) {
t.AppendSeparator()
}

for _, row := range extraRows {
t.AppendRow(row)
t.AppendSeparator()
}

t.Render()
}

Expand Down
Loading

0 comments on commit 9b23dfc

Please sign in to comment.