Пример #1
0
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.")
	}
}
Пример #2
0
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")
	}
}
Пример #3
0
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)
	}
}