From 70342314ae9019d0b27b890440cfccaad59fda30 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 19 May 2016 18:54:37 +0200 Subject: [PATCH] Allow to specify where to put default options in option desciption License: MIT Signed-off-by: Jakub Sztandera --- commands/option.go | 9 +++++++-- core/commands/publish.go | 7 +++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/commands/option.go b/commands/option.go index 5a48b523c..c7198a47d 100644 --- a/commands/option.go +++ b/commands/option.go @@ -3,6 +3,7 @@ package commands import ( "fmt" "reflect" + "strings" "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util" ) @@ -45,9 +46,13 @@ func (o *option) Description() string { if o.description[len(o.description)-1] != '.' { o.description += "." } - if o.defaultVal != nil { - return fmt.Sprintf("%s Default: %v.", o.description, o.defaultVal) + if strings.Contains(o.description, "") { + return strings.Replace(o.description, "", + fmt.Sprintf("Default: %v.", o.defaultVal), -1) + } else { + return fmt.Sprintf("%s Default: %v.", o.description, o.defaultVal) + } } return o.description } diff --git a/core/commands/publish.go b/core/commands/publish.go index d46e96edc..d0b31b864 100644 --- a/core/commands/publish.go +++ b/core/commands/publish.go @@ -51,11 +51,10 @@ Publish an to another public key (not implemented): }, Options: []cmds.Option{ 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. This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are - "ns", "us" (or "µs"), "ms", "s", "m", "h". - `).Default("24h"), + "ns", "us" (or "µs"), "ms", "s", "m", "h".`).Default("24h"), cmds.StringOption("ttl", "Time duration this record should be cached for (caution: experimental)."), }, Run: func(req cmds.Request, res cmds.Response) {