Skip to content

Commit

Permalink
List topics in tabular format
Browse files Browse the repository at this point in the history
  • Loading branch information
gkze committed Feb 5, 2019
1 parent c7e17e1 commit a012b57
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func main() {
cmdline := cli.NewApp()
cmdline.Name = "stars"
cmdline.Usage = "Command-line interface to YOUR GitHub stars"
cmdline.Version = "0.4.7"
cmdline.Version = "0.4.8"
cmdline.Commands = []cli.Command{
{
Name: "save",
Expand All @@ -33,14 +33,22 @@ func main() {
},
},
{
Name: "list-topics",
Name: "topics",
Usage: "list all topics of starred projects",
Action: func(c *cli.Context) error {
sm.SaveIfEmpty()
for _, pair := range sm.GetTopics() {
fmt.Println(pair.Key, pair.Value)
w := tabwriter.NewWriter(os.Stdout, 0, 8, 0, '\t', 0)

for i, pair := range sm.GetTopics() {
if i == 0 {
fmt.Fprintf(w, "TOPIC\tOCCURRENCES\n")
}

fmt.Fprintf(w, "%s\t%d\n", pair.Key, pair.Value)
}

w.Flush()

return nil
},
},
Expand Down

0 comments on commit a012b57

Please sign in to comment.