func FeedsAction(c *cli.Context) { a := aio.NewContext(c.GlobalString("key")) feeds, err := aio.Feeds(&a) if err != nil { log.Fatal(err) } if len(feeds) > 0 { for _, feed := range feeds { fmt.Println(feed.Name) } } else { fmt.Println("No feeds found.") } }
func GetAction(c *cli.Context) { log.Debug("Args: ", c.Args()) if len(c.Args()) == 0 { log.Fatal("feed id missing") } a := aio.NewContext(c.GlobalString("key")) id := c.Args().First() feed, err := aio.Find(id, &a) if err != nil { log.Fatal(err) } last_value := feed.Last_Value if last_value != "" { fmt.Println(last_value) } else { log.Fatal("last_value not set") } }
func SendAction(c *cli.Context) { log.Debug("Args: ", c.Args()) if len(c.Args()) == 0 { log.Fatal("feed id missing") } if len(c.Args()) == 1 { log.Fatal("value is missing") } a := aio.NewContext(c.GlobalString("key")) id := c.Args().First() val := c.Args()[len(c.Args())-1] err := aio.Send(id, val, &a) if err != nil { log.Fatal(err) } else { fmt.Println("OK", val) } }