Remove "prefix" format string. Use WithDefault("%s') for `-f- option.
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
Kevin Atkinson committed
Aug 24, 2018 at 23:19 UTC
30b861bc5a5f47683d587dd81ae4683672ace9fd
1 file changed
+5
-12
core/commands/cid.go
+5
-12
@@ -36,14 +36,14 @@ var cidFmtCmd = &cmds.Command{
36
LongDescription: `
37
Format and converts <cid>'s in various useful ways.
38
39
-The optional format string either "prefix" or or a printf style format string:
39
+The optional format string is a printf style format string:
40
` + cidutil.FormatRef,
41
},
42
Arguments: []cmdkit.Argument{
43
cmdkit.StringArg("cid", true, true, "Cids to format."),
44
},
45
Options: []cmdkit.Option{
46
- cmdkit.StringOption("f", "Format string."),
46
+ cmdkit.StringOption("f", "Printf style format string.").WithDefault("%s"),
47
cmdkit.StringOption("v", "CID version to convert to."),
48
cmdkit.StringOption("b", "Multibase to display CID in."),
49
},
@@ -54,17 +54,10 @@ The optional format string either "prefix" or or a printf style format string:
54
55
opts := cidFormatOpts{}
56
57
- switch fmtStr {
58
- case "":
59
- opts.fmtStr = "%s"
60
- case "prefix":
61
- opts.fmtStr = "%P"
62
- default:
63
- if strings.IndexByte(fmtStr, '%') == -1 {
64
- return fmt.Errorf("invalid format string: %s", fmtStr)
65
- }
66
- opts.fmtStr = fmtStr
57
+ if strings.IndexByte(fmtStr, '%') == -1 {
58
+ return fmt.Errorf("invalid format string: %s", fmtStr)
59
}
60
+ opts.fmtStr = fmtStr
61
62
switch verStr {
63
case "":