Esempio n. 1
0
func main() {
	locReqString := flag.String("requestedPage", "", "location in the request of the page")
	locCurString := flag.String("currentPage", "", "location in the response of the page returned")
	locTotalString := flag.String("totalPage", "", "location in the response of the total pages")
	username := flag.String("username", "", "username to use for authentication")
	password := flag.String("password", "", "username to use for authentication")
	url := flag.String("url", "", "url location to direct POSt")
	locInc := flag.Int("pageIncrement", 1, "number to increase location request by")
	delay := flag.Int("delay", 0, "seconds to wait between subsequent requests")

	flag.Parse()

	opts := config{
		username: *username,
		password: *password,
		url:      *url,
		locInc:   *locInc,
		locReq:   cliTricks.BreakupArray(*locReqString),
		locCur:   cliTricks.BreakupArray(*locCurString),
		locTotal: cliTricks.BreakupArray(*locTotalString),
		delay:    time.Duration(*delay) * time.Second,
	}

	err := ApiJsonRoundTrip(os.Stdin, os.Stdout, opts)
	if err != nil {
		log.Fatal(err)
	}
}
Esempio n. 2
0
func main() {
	var targetStrings stringSlice
	flag.Var(&targetStrings, "target", "locations to pluck from input")

	flag.Parse()

	var targets [][]interface{}
	for _, oneTarget := range targetStrings {
		targets = append(targets, cliTricks.BreakupArray(oneTarget))
	}

	if err := jsonDecoder(os.Stdin, os.Stdout, targets); err != nil {
		log.Print(err)
	}
}