Skip to content

Commit 8967517

Browse files
committedAug 12, 2024
Fixed issue when printing a falg information in builtin help command and it does not have a short flag
1 parent 236b137 commit 8967517

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
 

‎pkg/builtin/builtin_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ func FugazziFlags(cmd *rhombifer.Command) {
3131
Long: "A very long long description of the flag",
3232
ShortFormat: "f",
3333
}
34-
cmd.Flags = append(cmd.Flags, &foo)
34+
bar := models.Flag{
35+
Name: "Bar",
36+
Short: "A short description of bar",
37+
Long: "A very very long long description of the flag",
38+
}
39+
cmd.AddFlags(&foo, &bar)
3540
}
3641

3742
func OsArgs(expand string) []string {

‎pkg/builtin/help.cmd.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ func subHelp(cmd *rhombifer.Command) {
8181
fmt.Fprintf(w, "%v", text.Bold("Flags:"))
8282
if cmd.Flags != nil {
8383
for _, f := range cmd.Flags {
84-
fmt.Fprintf(w, "\n\t--%s\t-%s\t%s", f.Name, f.ShortFormat, f.Short)
84+
if f.ShortFormat != "" {
85+
fmt.Fprintf(w, "\n\t--%s\t-%s\t%s", f.Name, f.ShortFormat, f.Short)
86+
continue
87+
}
88+
fmt.Fprintf(w, "\n\t--%s\t\t%s", f.Name, f.Short)
8589
}
8690
fmt.Fprintf(w, "\n")
8791
w.Flush()

0 commit comments

Comments
 (0)
Please sign in to comment.