small pixel drawing of a pufferfish cascade

add printing of tags
Jes Olson j3s@c3f.net
Wed, 01 Mar 2023 20:41:35 -0800
commit

6bd1133e93b1a39ffa9bd01be64cafcc78f572a8

parent

932829649d1df3e287417a27563820e92660f40e

1 files changed, 13 insertions(+), 3 deletions(-)

jump to
M command/ls/members/members.gocommand/ls/members/members.go

@@ -5,6 +5,7 @@ "bytes"

"flag" "fmt" "os" + "strings" "text/tabwriter" "git.j3s.sh/cascade/api"

@@ -54,12 +55,13 @@

var b bytes.Buffer tw := tabwriter.NewWriter(&b, 0, 2, 2, ' ', 0) if membersFlags.details { - fmt.Fprintf(tw, "node\taddr\tstatus\n") + fmt.Fprintf(tw, "node\taddr\tstatus\ttags\n") } for _, m := range members { if membersFlags.details { - fmt.Fprintf(tw, "%s\t%s:%d\t%s\n", m.Name, m.Addr, m.Port, m.StatusPretty()) - } else { + fmt.Fprintf(tw, "%s\t%s:%d\t%s\t%v\n", m.Name, m.Addr, m.Port, m.StatusPretty(), printTags(m.Tags)) + } + if !membersFlags.details { fmt.Fprintf(tw, "%s\n", m.Name) } }

@@ -69,3 +71,11 @@ os.Exit(1)

} fmt.Print(b.String()) } + +func printTags(tags map[string]string) string { + var results []string + for k, v := range tags { + results = append(results, fmt.Sprintf("%s=%s", k, v)) + } + return strings.Join(results, ",") +}