Skip to content

Commit 6570e7f

Browse files
committed
add default value at help
1 parent b698a52 commit 6570e7f

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

application.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ func (ba *BaseApplication) Help(parts ...string) {
7070

7171
for _, param := range ba.params {
7272
alias := AddPrefix(param.alias, "-")
73-
fmt.Printf(" -%s | %s(%s)\n", param.identify, param.help, strings.Join(alias, ","))
73+
fmt.Printf(" -%s(%s) : %s(%s)\n", param.identify, param.defaultValue.String(), param.help, strings.Join(alias, ","))
7474
}
7575

7676
if len(ba.apps) > 0 {
7777
fmt.Println("Subcommands:")
7878
for _, app := range ba.apps {
7979
name, desc := app.Detail()
80-
fmt.Printf(" %s | %s\n", name, desc)
80+
fmt.Printf(" %s : %s\n", name, desc)
8181
}
8282
}
8383

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/b9o2/tabby
1+
module github.com/B9O2/tabby
22

33
go 1.21.6
44

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
github.com/B9O2/canvas v0.0.1 h1:H88iqvGOvOeS+Rpm7DK1yImrqdmFxpdnMloS6ufg/y0=
2-
github.com/B9O2/canvas v0.0.1/go.mod h1:GSMWTdkbZfQ5XB1kfu9R/jvaf/QQKSo2IJlz8bZfszs=
3-
github.com/B9O2/canvas v0.0.2 h1:chyEJ7R1Rx6AQFldgnAjyujmo8qZGNyw6HawMvtlwh8=
4-
github.com/B9O2/canvas v0.0.2/go.mod h1:GSMWTdkbZfQ5XB1kfu9R/jvaf/QQKSo2IJlz8bZfszs=
51
github.com/B9O2/canvas v0.0.3 h1:y66IE61wSWSV1MULIo78bVrzvQwa2Gq991ZqKa5rnfo=
62
github.com/B9O2/canvas v0.0.3/go.mod h1:GSMWTdkbZfQ5XB1kfu9R/jvaf/QQKSo2IJlz8bZfszs=

tabby.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ type DefaultValue struct {
3636
transfer func(string) (any, error)
3737
}
3838

39+
func (dv DefaultValue) String() string {
40+
return fmt.Sprint(dv.value)
41+
}
42+
3943
func DefaultParser(rawArgs []string) (map[string]string, error) {
4044
//RawArgs
4145
currentKey := ""
@@ -168,8 +172,6 @@ func (t *Tabby) Run(rawArgs []string) (*TabbyContainer, error) {
168172
"App '%s': required parameter '%s' not provided(%s)",
169173
finalAppPath, param.identify,
170174
strings.Join(AddPrefix(param.alias, "-"), ","))
171-
} else {
172-
173175
}
174176
}
175177
}

0 commit comments

Comments
 (0)