mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-23 21:47:52 +08:00
Merge pull request #2744 from ipfs/feature/Options-Default-2702
Allow to specify where to put default options in option desciption
This commit is contained in:
@ -3,6 +3,7 @@ package commands
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
|
"gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
|
||||||
)
|
)
|
||||||
@ -45,10 +46,14 @@ func (o *option) Description() string {
|
|||||||
if o.description[len(o.description)-1] != '.' {
|
if o.description[len(o.description)-1] != '.' {
|
||||||
o.description += "."
|
o.description += "."
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.defaultVal != nil {
|
if o.defaultVal != nil {
|
||||||
|
if strings.Contains(o.description, "<default>") {
|
||||||
|
return strings.Replace(o.description, "<default>",
|
||||||
|
fmt.Sprintf("Default: %v.", o.defaultVal), -1)
|
||||||
|
} else {
|
||||||
return fmt.Sprintf("%s Default: %v.", o.description, o.defaultVal)
|
return fmt.Sprintf("%s Default: %v.", o.description, o.defaultVal)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return o.description
|
return o.description
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +51,10 @@ Publish an <ipfs-path> to another public key (not implemented):
|
|||||||
},
|
},
|
||||||
Options: []cmds.Option{
|
Options: []cmds.Option{
|
||||||
cmds.BoolOption("resolve", "Resolve given path before publishing.").Default(true),
|
cmds.BoolOption("resolve", "Resolve given path before publishing.").Default(true),
|
||||||
cmds.StringOption("lifetime", "t", `Time duration that the record will be valid for.
|
cmds.StringOption("lifetime", "t",
|
||||||
|
`Time duration that the record will be valid for. <default>
|
||||||
This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are
|
This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are
|
||||||
"ns", "us" (or "µs"), "ms", "s", "m", "h".
|
"ns", "us" (or "µs"), "ms", "s", "m", "h".`).Default("24h"),
|
||||||
`).Default("24h"),
|
|
||||||
cmds.StringOption("ttl", "Time duration this record should be cached for (caution: experimental)."),
|
cmds.StringOption("ttl", "Time duration this record should be cached for (caution: experimental)."),
|
||||||
},
|
},
|
||||||
Run: func(req cmds.Request, res cmds.Response) {
|
Run: func(req cmds.Request, res cmds.Response) {
|
||||||
|
Reference in New Issue
Block a user