Exemplo n.º 1
0
func main() {
	lyticsBanner()
	apikey := os.Getenv("LIOKEY")
	if apikey == "" {
		fmt.Println("must have  LIOKEY env set")
		usageExit()
		os.Exit(1)
	}
	if len(os.Args) < 2 {
		usageExit()
	}

	// create the client
	client := lytics.NewLytics(apikey, nil, nil)

	// create the scanner
	scan := client.PageSegmentId(os.Args[1])

	// handle processing the entities
	for {
		e := scan.Next()
		if e == nil {
			break
		}

		fmt.Printf("%v\n\n", e.PrettyJson())
	}

	fmt.Printf("*** COMPLETED SCAN: Loaded %d total entities\n\n", scan.Total)
}
Exemplo n.º 2
0
func main() {
	if apikey == "" && dataapikey == "" {
		fmt.Println(`Missing -apikey and/or -method: use -help for assistance

    LIOKEY env variable will fullfill api key needs
    `)
		os.Exit(1)
	}

	if len(flag.Args()) < 1 {
		flag.Usage()
		return
	}
	method = flag.Args()[0]

	// create lytics client with auth info
	c := Cli{
		Client: lytics.NewLytics(apikey, dataapikey, nil),
	}

	output, err := c.handleFunction(method)
	if err != nil {
		fmt.Println(fmt.Sprintf("Error: %v", err))
		os.Exit(1)
	}

	if file != "" {
		err := writeToFile(file, output)
		if err != nil {
			fmt.Println("Failed to write data to file %s: %v", file, err)
			return
		}

		fmt.Println("Data written to %s successfully.", file)
		return
	}

	fmt.Println(output)
}