Skip to content

Commit

Permalink
Added Default logic to refs
Browse files Browse the repository at this point in the history
Not sure about the switch statement. There may be a more elegant solution.

Part of #2484

License: MIT
Signed-off-by: Richard Littauer <richard.littauer@gmail.com>
  • Loading branch information
RichardLitt committed May 12, 2016
1 parent a2bcec4 commit 2fb0e23
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/commands/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ NOTE: List all references recursively by using the flag '-r'.
cmds.StringArg("ipfs-path", true, true, "Path to the object(s) to list refs from.").EnableStdin(),
},
Options: []cmds.Option{
cmds.StringOption("format", "Emit edges with given format. Available tokens: <src> <dst> <linkname>."),
cmds.StringOption("format", "Emit edges with given format. Available tokens: <src> <dst> <linkname>.").Default("<dst>"),
cmds.BoolOption("edges", "e", "Emit edge format: `<from> -> <to>`.").Default(false),
cmds.BoolOption("unique", "u", "Omit duplicate refs from output.").Default(false),
cmds.BoolOption("recursive", "r", "Recursively list links of child nodes.").Default(false),
Expand Down Expand Up @@ -313,6 +313,8 @@ func (rw *RefWriter) WriteEdge(from, to key.Key, linkname string) error {

var s string
switch {
case rw.PrintFmt == "<dst>":
s += to.B58String()
case rw.PrintFmt != "":
s = rw.PrintFmt
s = strings.Replace(s, "<src>", from.B58String(), -1)
Expand Down

0 comments on commit 2fb0e23

Please sign in to comment.