Skip to content

Commit 518f7e0

Browse files
committed
Merge pull request #2744 from ipfs/feature/Options-Default-2702
Allow to specify where to put default options in option desciption
2 parents 425e0f0 + 7034231 commit 518f7e0

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

commands/option.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package commands
33
import (
44
"fmt"
55
"reflect"
6+
"strings"
67

78
"gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
89
)
@@ -45,9 +46,13 @@ func (o *option) Description() string {
4546
if o.description[len(o.description)-1] != '.' {
4647
o.description += "."
4748
}
48-
4949
if o.defaultVal != nil {
50-
return fmt.Sprintf("%s Default: %v.", o.description, o.defaultVal)
50+
if strings.Contains(o.description, "<default>") {
51+
return strings.Replace(o.description, "<default>",
52+
fmt.Sprintf("Default: %v.", o.defaultVal), -1)
53+
} else {
54+
return fmt.Sprintf("%s Default: %v.", o.description, o.defaultVal)
55+
}
5156
}
5257
return o.description
5358
}

core/commands/publish.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ Publish an <ipfs-path> to another public key (not implemented):
5151
},
5252
Options: []cmds.Option{
5353
cmds.BoolOption("resolve", "Resolve given path before publishing.").Default(true),
54-
cmds.StringOption("lifetime", "t", `Time duration that the record will be valid for.
55-
54+
cmds.StringOption("lifetime", "t",
55+
`Time duration that the record will be valid for. <default>
5656
This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are
57-
"ns", "us" (or "µs"), "ms", "s", "m", "h".
58-
`).Default("24h"),
57+
"ns", "us" (or "µs"), "ms", "s", "m", "h".`).Default("24h"),
5958
cmds.StringOption("ttl", "Time duration this record should be cached for (caution: experimental)."),
6059
},
6160
Run: func(req cmds.Request, res cmds.Response) {

0 commit comments

Comments
 (0)