示例#1
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewPushManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "enablePushNotification":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "EnablePushNotification requires 4 args")
			flag.Usage()
		}
		argvalue0, err1535 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1535 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		argvalue2 := flag.Arg(3) == "true"
		value2 := argvalue2
		arg1538 := flag.Arg(4)
		mbTrans1539 := thrift.NewTMemoryBufferLen(len(arg1538))
		defer mbTrans1539.Close()
		_, err1540 := mbTrans1539.WriteString(arg1538)
		if err1540 != nil {
			Usage()
			return
		}
		factory1541 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1542 := factory1541.GetProtocol(mbTrans1539)
		argvalue3 := services.NewFromInfo()
		err1543 := argvalue3.Read(jsProt1542)
		if err1543 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.EnablePushNotification(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
示例#2
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewSearchManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "searchPublicResources":
		if flag.NArg()-1 != 9 {
			fmt.Fprintln(os.Stderr, "SearchPublicResources requires 9 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.SearchCategory(tmp1)
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceType(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.Zone(tmp3)
		value3 := argvalue3
		tmp4, err1256 := (strconv.Atoi(flag.Arg(5)))
		if err1256 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		tmp5, err1257 := (strconv.Atoi(flag.Arg(6)))
		if err1257 != nil {
			Usage()
			return
		}
		argvalue5 := int32(tmp5)
		value5 := argvalue5
		arg1258 := flag.Arg(7)
		mbTrans1259 := thrift.NewTMemoryBufferLen(len(arg1258))
		defer mbTrans1259.Close()
		_, err1260 := mbTrans1259.WriteString(arg1258)
		if err1260 != nil {
			Usage()
			return
		}
		factory1261 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1262 := factory1261.GetProtocol(mbTrans1259)
		containerStruct6 := services.NewSearchPublicResourcesArgs()
		err1263 := containerStruct6.ReadField7(jsProt1262)
		if err1263 != nil {
			Usage()
			return
		}
		argvalue6 := containerStruct6.Sortlist
		value6 := argvalue6
		arg1264 := flag.Arg(8)
		mbTrans1265 := thrift.NewTMemoryBufferLen(len(arg1264))
		defer mbTrans1265.Close()
		_, err1266 := mbTrans1265.WriteString(arg1264)
		if err1266 != nil {
			Usage()
			return
		}
		factory1267 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1268 := factory1267.GetProtocol(mbTrans1265)
		containerStruct7 := services.NewSearchPublicResourcesArgs()
		err1269 := containerStruct7.ReadField8(jsProt1268)
		if err1269 != nil {
			Usage()
			return
		}
		argvalue7 := containerStruct7.Filterlist
		value7 := argvalue7
		arg1270 := flag.Arg(9)
		mbTrans1271 := thrift.NewTMemoryBufferLen(len(arg1270))
		defer mbTrans1271.Close()
		_, err1272 := mbTrans1271.WriteString(arg1270)
		if err1272 != nil {
			Usage()
			return
		}
		factory1273 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1274 := factory1273.GetProtocol(mbTrans1271)
		argvalue8 := services.NewFromInfo()
		err1275 := argvalue8.Read(jsProt1274)
		if err1275 != nil {
			Usage()
			return
		}
		value8 := argvalue8
		fmt.Print(client.SearchPublicResources(value0, value1, value2, value3, value4, value5, value6, value7, value8))
		fmt.Print("\n")
		break
	case "searchGroupResources":
		if flag.NArg()-1 != 9 {
			fmt.Fprintln(os.Stderr, "SearchGroupResources requires 9 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1, err1277 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1277 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceType(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.Zone(tmp3)
		value3 := argvalue3
		tmp4, err1278 := (strconv.Atoi(flag.Arg(5)))
		if err1278 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		tmp5, err1279 := (strconv.Atoi(flag.Arg(6)))
		if err1279 != nil {
			Usage()
			return
		}
		argvalue5 := int32(tmp5)
		value5 := argvalue5
		arg1280 := flag.Arg(7)
		mbTrans1281 := thrift.NewTMemoryBufferLen(len(arg1280))
		defer mbTrans1281.Close()
		_, err1282 := mbTrans1281.WriteString(arg1280)
		if err1282 != nil {
			Usage()
			return
		}
		factory1283 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1284 := factory1283.GetProtocol(mbTrans1281)
		containerStruct6 := services.NewSearchGroupResourcesArgs()
		err1285 := containerStruct6.ReadField7(jsProt1284)
		if err1285 != nil {
			Usage()
			return
		}
		argvalue6 := containerStruct6.Sortlist
		value6 := argvalue6
		arg1286 := flag.Arg(8)
		mbTrans1287 := thrift.NewTMemoryBufferLen(len(arg1286))
		defer mbTrans1287.Close()
		_, err1288 := mbTrans1287.WriteString(arg1286)
		if err1288 != nil {
			Usage()
			return
		}
		factory1289 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1290 := factory1289.GetProtocol(mbTrans1287)
		containerStruct7 := services.NewSearchGroupResourcesArgs()
		err1291 := containerStruct7.ReadField8(jsProt1290)
		if err1291 != nil {
			Usage()
			return
		}
		argvalue7 := containerStruct7.Filterlist
		value7 := argvalue7
		arg1292 := flag.Arg(9)
		mbTrans1293 := thrift.NewTMemoryBufferLen(len(arg1292))
		defer mbTrans1293.Close()
		_, err1294 := mbTrans1293.WriteString(arg1292)
		if err1294 != nil {
			Usage()
			return
		}
		factory1295 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1296 := factory1295.GetProtocol(mbTrans1293)
		argvalue8 := services.NewFromInfo()
		err1297 := argvalue8.Read(jsProt1296)
		if err1297 != nil {
			Usage()
			return
		}
		value8 := argvalue8
		fmt.Print(client.SearchGroupResources(value0, value1, value2, value3, value4, value5, value6, value7, value8))
		fmt.Print("\n")
		break
	case "searchGroup":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "SearchGroup requires 7 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.GroupType(tmp1)
		value1 := argvalue1
		tmp2, err1299 := (strconv.Atoi(flag.Arg(3)))
		if err1299 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err1300 := (strconv.Atoi(flag.Arg(4)))
		if err1300 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		arg1301 := flag.Arg(5)
		mbTrans1302 := thrift.NewTMemoryBufferLen(len(arg1301))
		defer mbTrans1302.Close()
		_, err1303 := mbTrans1302.WriteString(arg1301)
		if err1303 != nil {
			Usage()
			return
		}
		factory1304 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1305 := factory1304.GetProtocol(mbTrans1302)
		containerStruct4 := services.NewSearchGroupArgs()
		err1306 := containerStruct4.ReadField5(jsProt1305)
		if err1306 != nil {
			Usage()
			return
		}
		argvalue4 := containerStruct4.Sortlist
		value4 := argvalue4
		arg1307 := flag.Arg(6)
		mbTrans1308 := thrift.NewTMemoryBufferLen(len(arg1307))
		defer mbTrans1308.Close()
		_, err1309 := mbTrans1308.WriteString(arg1307)
		if err1309 != nil {
			Usage()
			return
		}
		factory1310 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1311 := factory1310.GetProtocol(mbTrans1308)
		containerStruct5 := services.NewSearchGroupArgs()
		err1312 := containerStruct5.ReadField6(jsProt1311)
		if err1312 != nil {
			Usage()
			return
		}
		argvalue5 := containerStruct5.Filterlist
		value5 := argvalue5
		arg1313 := flag.Arg(7)
		mbTrans1314 := thrift.NewTMemoryBufferLen(len(arg1313))
		defer mbTrans1314.Close()
		_, err1315 := mbTrans1314.WriteString(arg1313)
		if err1315 != nil {
			Usage()
			return
		}
		factory1316 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1317 := factory1316.GetProtocol(mbTrans1314)
		argvalue6 := services.NewFromInfo()
		err1318 := argvalue6.Read(jsProt1317)
		if err1318 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.SearchGroup(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "searchUser":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "SearchUser requires 4 args")
			flag.Usage()
		}
		arg1319 := flag.Arg(1)
		mbTrans1320 := thrift.NewTMemoryBufferLen(len(arg1319))
		defer mbTrans1320.Close()
		_, err1321 := mbTrans1320.WriteString(arg1319)
		if err1321 != nil {
			Usage()
			return
		}
		factory1322 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1323 := factory1322.GetProtocol(mbTrans1320)
		argvalue0 := services.NewUserSearchInfo()
		err1324 := argvalue0.Read(jsProt1323)
		if err1324 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg1325 := flag.Arg(2)
		mbTrans1326 := thrift.NewTMemoryBufferLen(len(arg1325))
		defer mbTrans1326.Close()
		_, err1327 := mbTrans1326.WriteString(arg1325)
		if err1327 != nil {
			Usage()
			return
		}
		factory1328 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1329 := factory1328.GetProtocol(mbTrans1326)
		containerStruct1 := services.NewSearchUserArgs()
		err1330 := containerStruct1.ReadField2(jsProt1329)
		if err1330 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.Sortlist
		value1 := argvalue1
		arg1331 := flag.Arg(3)
		mbTrans1332 := thrift.NewTMemoryBufferLen(len(arg1331))
		defer mbTrans1332.Close()
		_, err1333 := mbTrans1332.WriteString(arg1331)
		if err1333 != nil {
			Usage()
			return
		}
		factory1334 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1335 := factory1334.GetProtocol(mbTrans1332)
		containerStruct2 := services.NewSearchUserArgs()
		err1336 := containerStruct2.ReadField3(jsProt1335)
		if err1336 != nil {
			Usage()
			return
		}
		argvalue2 := containerStruct2.Filterlist
		value2 := argvalue2
		arg1337 := flag.Arg(4)
		mbTrans1338 := thrift.NewTMemoryBufferLen(len(arg1337))
		defer mbTrans1338.Close()
		_, err1339 := mbTrans1338.WriteString(arg1337)
		if err1339 != nil {
			Usage()
			return
		}
		factory1340 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1341 := factory1340.GetProtocol(mbTrans1338)
		argvalue3 := services.NewFromInfo()
		err1342 := argvalue3.Read(jsProt1341)
		if err1342 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.SearchUser(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "searchResourceByTag":
		if flag.NArg()-1 != 8 {
			fmt.Fprintln(os.Stderr, "SearchResourceByTag requires 8 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.ResourceType(tmp1)
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.Zone(tmp2)
		value2 := argvalue2
		tmp3, err1344 := (strconv.Atoi(flag.Arg(4)))
		if err1344 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		tmp4, err1345 := (strconv.Atoi(flag.Arg(5)))
		if err1345 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		arg1346 := flag.Arg(6)
		mbTrans1347 := thrift.NewTMemoryBufferLen(len(arg1346))
		defer mbTrans1347.Close()
		_, err1348 := mbTrans1347.WriteString(arg1346)
		if err1348 != nil {
			Usage()
			return
		}
		factory1349 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1350 := factory1349.GetProtocol(mbTrans1347)
		containerStruct5 := services.NewSearchResourceByTagArgs()
		err1351 := containerStruct5.ReadField6(jsProt1350)
		if err1351 != nil {
			Usage()
			return
		}
		argvalue5 := containerStruct5.Sortlist
		value5 := argvalue5
		arg1352 := flag.Arg(7)
		mbTrans1353 := thrift.NewTMemoryBufferLen(len(arg1352))
		defer mbTrans1353.Close()
		_, err1354 := mbTrans1353.WriteString(arg1352)
		if err1354 != nil {
			Usage()
			return
		}
		factory1355 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1356 := factory1355.GetProtocol(mbTrans1353)
		containerStruct6 := services.NewSearchResourceByTagArgs()
		err1357 := containerStruct6.ReadField7(jsProt1356)
		if err1357 != nil {
			Usage()
			return
		}
		argvalue6 := containerStruct6.Filterlist
		value6 := argvalue6
		arg1358 := flag.Arg(8)
		mbTrans1359 := thrift.NewTMemoryBufferLen(len(arg1358))
		defer mbTrans1359.Close()
		_, err1360 := mbTrans1359.WriteString(arg1358)
		if err1360 != nil {
			Usage()
			return
		}
		factory1361 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1362 := factory1361.GetProtocol(mbTrans1359)
		argvalue7 := services.NewFromInfo()
		err1363 := argvalue7.Read(jsProt1362)
		if err1363 != nil {
			Usage()
			return
		}
		value7 := argvalue7
		fmt.Print(client.SearchResourceByTag(value0, value1, value2, value3, value4, value5, value6, value7))
		fmt.Print("\n")
		break
	case "searchGroupIds":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "SearchGroupIds requires 5 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.Zone(tmp1)
		value1 := argvalue1
		arg1365 := flag.Arg(3)
		mbTrans1366 := thrift.NewTMemoryBufferLen(len(arg1365))
		defer mbTrans1366.Close()
		_, err1367 := mbTrans1366.WriteString(arg1365)
		if err1367 != nil {
			Usage()
			return
		}
		factory1368 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1369 := factory1368.GetProtocol(mbTrans1366)
		containerStruct2 := services.NewSearchGroupIdsArgs()
		err1370 := containerStruct2.ReadField3(jsProt1369)
		if err1370 != nil {
			Usage()
			return
		}
		argvalue2 := containerStruct2.Sortlist
		value2 := argvalue2
		arg1371 := flag.Arg(4)
		mbTrans1372 := thrift.NewTMemoryBufferLen(len(arg1371))
		defer mbTrans1372.Close()
		_, err1373 := mbTrans1372.WriteString(arg1371)
		if err1373 != nil {
			Usage()
			return
		}
		factory1374 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1375 := factory1374.GetProtocol(mbTrans1372)
		containerStruct3 := services.NewSearchGroupIdsArgs()
		err1376 := containerStruct3.ReadField4(jsProt1375)
		if err1376 != nil {
			Usage()
			return
		}
		argvalue3 := containerStruct3.Filterlist
		value3 := argvalue3
		arg1377 := flag.Arg(5)
		mbTrans1378 := thrift.NewTMemoryBufferLen(len(arg1377))
		defer mbTrans1378.Close()
		_, err1379 := mbTrans1378.WriteString(arg1377)
		if err1379 != nil {
			Usage()
			return
		}
		factory1380 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1381 := factory1380.GetProtocol(mbTrans1378)
		argvalue4 := services.NewFromInfo()
		err1382 := argvalue4.Read(jsProt1381)
		if err1382 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.SearchGroupIds(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "searchTags":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "SearchTags requires 4 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err1384 := (strconv.Atoi(flag.Arg(2)))
		if err1384 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		tmp2, err1385 := (strconv.Atoi(flag.Arg(3)))
		if err1385 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		arg1386 := flag.Arg(4)
		mbTrans1387 := thrift.NewTMemoryBufferLen(len(arg1386))
		defer mbTrans1387.Close()
		_, err1388 := mbTrans1387.WriteString(arg1386)
		if err1388 != nil {
			Usage()
			return
		}
		factory1389 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1390 := factory1389.GetProtocol(mbTrans1387)
		argvalue3 := services.NewFromInfo()
		err1391 := argvalue3.Read(jsProt1390)
		if err1391 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.SearchTags(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewRecommendationManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "getResourceRecommendation":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "GetResourceRecommendation requires 7 args")
			flag.Usage()
		}
		argvalue0, err1405 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1405 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.ResourceType(tmp1)
		value1 := argvalue1
		tmp2, err1406 := (strconv.Atoi(flag.Arg(3)))
		if err1406 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err1407 := (strconv.Atoi(flag.Arg(4)))
		if err1407 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		arg1408 := flag.Arg(5)
		mbTrans1409 := thrift.NewTMemoryBufferLen(len(arg1408))
		defer mbTrans1409.Close()
		_, err1410 := mbTrans1409.WriteString(arg1408)
		if err1410 != nil {
			Usage()
			return
		}
		factory1411 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1412 := factory1411.GetProtocol(mbTrans1409)
		argvalue4 := services.NewRecommendationAugmentInfo()
		err1413 := argvalue4.Read(jsProt1412)
		if err1413 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		tmp5, err := (strconv.Atoi(flag.Arg(6)))
		if err != nil {
			Usage()
			return
		}
		argvalue5 := services.RecommendationReason(tmp5)
		value5 := argvalue5
		arg1414 := flag.Arg(7)
		mbTrans1415 := thrift.NewTMemoryBufferLen(len(arg1414))
		defer mbTrans1415.Close()
		_, err1416 := mbTrans1415.WriteString(arg1414)
		if err1416 != nil {
			Usage()
			return
		}
		factory1417 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1418 := factory1417.GetProtocol(mbTrans1415)
		argvalue6 := services.NewFromInfo()
		err1419 := argvalue6.Read(jsProt1418)
		if err1419 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.GetResourceRecommendation(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "getGroupRecommendation":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GetGroupRecommendation requires 6 args")
			flag.Usage()
		}
		argvalue0, err1420 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1420 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err1421 := (strconv.Atoi(flag.Arg(2)))
		if err1421 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		tmp2, err1422 := (strconv.Atoi(flag.Arg(3)))
		if err1422 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.RecommendationReason(tmp3)
		value3 := argvalue3
		arg1423 := flag.Arg(5)
		mbTrans1424 := thrift.NewTMemoryBufferLen(len(arg1423))
		defer mbTrans1424.Close()
		_, err1425 := mbTrans1424.WriteString(arg1423)
		if err1425 != nil {
			Usage()
			return
		}
		factory1426 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1427 := factory1426.GetProtocol(mbTrans1424)
		argvalue4 := services.NewRecommendationAugmentInfo()
		err1428 := argvalue4.Read(jsProt1427)
		if err1428 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		arg1429 := flag.Arg(6)
		mbTrans1430 := thrift.NewTMemoryBufferLen(len(arg1429))
		defer mbTrans1430.Close()
		_, err1431 := mbTrans1430.WriteString(arg1429)
		if err1431 != nil {
			Usage()
			return
		}
		factory1432 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1433 := factory1432.GetProtocol(mbTrans1430)
		argvalue5 := services.NewFromInfo()
		err1434 := argvalue5.Read(jsProt1433)
		if err1434 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.GetGroupRecommendation(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "getTagRecommendation":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "GetTagRecommendation requires 7 args")
			flag.Usage()
		}
		argvalue0, err1435 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1435 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg1436 := flag.Arg(2)
		mbTrans1437 := thrift.NewTMemoryBufferLen(len(arg1436))
		defer mbTrans1437.Close()
		_, err1438 := mbTrans1437.WriteString(arg1436)
		if err1438 != nil {
			Usage()
			return
		}
		factory1439 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1440 := factory1439.GetProtocol(mbTrans1437)
		containerStruct1 := services.NewGetTagRecommendationArgs()
		err1441 := containerStruct1.ReadField2(jsProt1440)
		if err1441 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.TagList
		value1 := argvalue1
		tmp2, err1442 := (strconv.Atoi(flag.Arg(3)))
		if err1442 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err1443 := (strconv.Atoi(flag.Arg(4)))
		if err1443 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		tmp4, err := (strconv.Atoi(flag.Arg(5)))
		if err != nil {
			Usage()
			return
		}
		argvalue4 := services.RecommendationReason(tmp4)
		value4 := argvalue4
		tmp5, err := (strconv.Atoi(flag.Arg(6)))
		if err != nil {
			Usage()
			return
		}
		argvalue5 := services.ResourceType(tmp5)
		value5 := argvalue5
		arg1444 := flag.Arg(7)
		mbTrans1445 := thrift.NewTMemoryBufferLen(len(arg1444))
		defer mbTrans1445.Close()
		_, err1446 := mbTrans1445.WriteString(arg1444)
		if err1446 != nil {
			Usage()
			return
		}
		factory1447 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1448 := factory1447.GetProtocol(mbTrans1445)
		argvalue6 := services.NewFromInfo()
		err1449 := argvalue6.Read(jsProt1448)
		if err1449 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.GetTagRecommendation(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "getFriendRecommendation":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "GetFriendRecommendation requires 5 args")
			flag.Usage()
		}
		argvalue0, err1450 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1450 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err1451 := (strconv.Atoi(flag.Arg(2)))
		if err1451 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		tmp2, err1452 := (strconv.Atoi(flag.Arg(3)))
		if err1452 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.RecommendationReason(tmp3)
		value3 := argvalue3
		arg1453 := flag.Arg(5)
		mbTrans1454 := thrift.NewTMemoryBufferLen(len(arg1453))
		defer mbTrans1454.Close()
		_, err1455 := mbTrans1454.WriteString(arg1453)
		if err1455 != nil {
			Usage()
			return
		}
		factory1456 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1457 := factory1456.GetProtocol(mbTrans1454)
		argvalue4 := services.NewFromInfo()
		err1458 := argvalue4.Read(jsProt1457)
		if err1458 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.GetFriendRecommendation(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "getRecommendationByMix":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GetRecommendationByMix requires 6 args")
			flag.Usage()
		}
		argvalue0, err1459 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1459 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err1460 := (strconv.Atoi(flag.Arg(2)))
		if err1460 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		tmp2, err1461 := (strconv.Atoi(flag.Arg(3)))
		if err1461 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.RecommendationReason(tmp3)
		value3 := argvalue3
		arg1462 := flag.Arg(5)
		mbTrans1463 := thrift.NewTMemoryBufferLen(len(arg1462))
		defer mbTrans1463.Close()
		_, err1464 := mbTrans1463.WriteString(arg1462)
		if err1464 != nil {
			Usage()
			return
		}
		factory1465 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1466 := factory1465.GetProtocol(mbTrans1463)
		argvalue4 := services.NewRecommendationAugmentInfo()
		err1467 := argvalue4.Read(jsProt1466)
		if err1467 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		arg1468 := flag.Arg(6)
		mbTrans1469 := thrift.NewTMemoryBufferLen(len(arg1468))
		defer mbTrans1469.Close()
		_, err1470 := mbTrans1469.WriteString(arg1468)
		if err1470 != nil {
			Usage()
			return
		}
		factory1471 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1472 := factory1471.GetProtocol(mbTrans1469)
		argvalue5 := services.NewFromInfo()
		err1473 := argvalue5.Read(jsProt1472)
		if err1473 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.GetRecommendationByMix(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
示例#4
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewTagManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "addTag":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "AddTag requires 5 args")
			flag.Usage()
		}
		argvalue0, err1486 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1486 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1487 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1487 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceType(tmp2)
		value2 := argvalue2
		arg1488 := flag.Arg(4)
		mbTrans1489 := thrift.NewTMemoryBufferLen(len(arg1488))
		defer mbTrans1489.Close()
		_, err1490 := mbTrans1489.WriteString(arg1488)
		if err1490 != nil {
			Usage()
			return
		}
		factory1491 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1492 := factory1491.GetProtocol(mbTrans1489)
		containerStruct3 := services.NewAddTagArgs()
		err1493 := containerStruct3.ReadField4(jsProt1492)
		if err1493 != nil {
			Usage()
			return
		}
		argvalue3 := containerStruct3.Tags
		value3 := argvalue3
		arg1494 := flag.Arg(5)
		mbTrans1495 := thrift.NewTMemoryBufferLen(len(arg1494))
		defer mbTrans1495.Close()
		_, err1496 := mbTrans1495.WriteString(arg1494)
		if err1496 != nil {
			Usage()
			return
		}
		factory1497 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1498 := factory1497.GetProtocol(mbTrans1495)
		argvalue4 := services.NewFromInfo()
		err1499 := argvalue4.Read(jsProt1498)
		if err1499 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.AddTag(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "getTags":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "GetTags requires 3 args")
			flag.Usage()
		}
		argvalue0, err1500 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1500 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1501 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1501 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg1502 := flag.Arg(3)
		mbTrans1503 := thrift.NewTMemoryBufferLen(len(arg1502))
		defer mbTrans1503.Close()
		_, err1504 := mbTrans1503.WriteString(arg1502)
		if err1504 != nil {
			Usage()
			return
		}
		factory1505 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1506 := factory1505.GetProtocol(mbTrans1503)
		argvalue2 := services.NewFromInfo()
		err1507 := argvalue2.Read(jsProt1506)
		if err1507 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.GetTags(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getTagsByUid":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "GetTagsByUid requires 4 args")
			flag.Usage()
		}
		argvalue0, err1508 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1508 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1509 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1509 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err1510 := (strconv.Atoi(flag.Arg(3)))
		if err1510 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		arg1511 := flag.Arg(4)
		mbTrans1512 := thrift.NewTMemoryBufferLen(len(arg1511))
		defer mbTrans1512.Close()
		_, err1513 := mbTrans1512.WriteString(arg1511)
		if err1513 != nil {
			Usage()
			return
		}
		factory1514 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1515 := factory1514.GetProtocol(mbTrans1512)
		argvalue3 := services.NewFromInfo()
		err1516 := argvalue3.Read(jsProt1515)
		if err1516 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.GetTagsByUid(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "updateTags":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "UpdateTags requires 5 args")
			flag.Usage()
		}
		argvalue0, err1517 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1517 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1518 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1518 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceType(tmp2)
		value2 := argvalue2
		arg1519 := flag.Arg(4)
		mbTrans1520 := thrift.NewTMemoryBufferLen(len(arg1519))
		defer mbTrans1520.Close()
		_, err1521 := mbTrans1520.WriteString(arg1519)
		if err1521 != nil {
			Usage()
			return
		}
		factory1522 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1523 := factory1522.GetProtocol(mbTrans1520)
		containerStruct3 := services.NewUpdateTagsArgs()
		err1524 := containerStruct3.ReadField4(jsProt1523)
		if err1524 != nil {
			Usage()
			return
		}
		argvalue3 := containerStruct3.Tags
		value3 := argvalue3
		arg1525 := flag.Arg(5)
		mbTrans1526 := thrift.NewTMemoryBufferLen(len(arg1525))
		defer mbTrans1526.Close()
		_, err1527 := mbTrans1526.WriteString(arg1525)
		if err1527 != nil {
			Usage()
			return
		}
		factory1528 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1529 := factory1528.GetProtocol(mbTrans1526)
		argvalue4 := services.NewFromInfo()
		err1530 := argvalue4.Read(jsProt1529)
		if err1530 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.UpdateTags(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewUserRelationManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "setRemark":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "SetRemark requires 3 args")
			flag.Usage()
		}
		argvalue0, err595 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err595 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		arg597 := flag.Arg(3)
		mbTrans598 := thrift.NewTMemoryBufferLen(len(arg597))
		defer mbTrans598.Close()
		_, err599 := mbTrans598.WriteString(arg597)
		if err599 != nil {
			Usage()
			return
		}
		factory600 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt601 := factory600.GetProtocol(mbTrans598)
		argvalue2 := services.NewFromInfo()
		err602 := argvalue2.Read(jsProt601)
		if err602 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.SetRemark(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getRemarks":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "GetRemarks requires 3 args")
			flag.Usage()
		}
		argvalue0, err603 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err603 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err604 := (strconv.Atoi(flag.Arg(2)))
		if err604 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		arg605 := flag.Arg(3)
		mbTrans606 := thrift.NewTMemoryBufferLen(len(arg605))
		defer mbTrans606.Close()
		_, err607 := mbTrans606.WriteString(arg605)
		if err607 != nil {
			Usage()
			return
		}
		factory608 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt609 := factory608.GetProtocol(mbTrans606)
		argvalue2 := services.NewFromInfo()
		err610 := argvalue2.Read(jsProt609)
		if err610 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.GetRemarks(value0, value1, value2))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
示例#6
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewRemindingManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "getRemindingMsgs":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetRemindingMsgs requires 2 args")
			flag.Usage()
		}
		argvalue0, err1580 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1580 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg1581 := flag.Arg(2)
		mbTrans1582 := thrift.NewTMemoryBufferLen(len(arg1581))
		defer mbTrans1582.Close()
		_, err1583 := mbTrans1582.WriteString(arg1581)
		if err1583 != nil {
			Usage()
			return
		}
		factory1584 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1585 := factory1584.GetProtocol(mbTrans1582)
		argvalue1 := services.NewFromInfo()
		err1586 := argvalue1.Read(jsProt1585)
		if err1586 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetRemindingMsgs(value0, value1))
		fmt.Print("\n")
		break
	case "deleteRemindingMsg":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "DeleteRemindingMsg requires 2 args")
			flag.Usage()
		}
		argvalue0, err1587 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1587 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg1588 := flag.Arg(2)
		mbTrans1589 := thrift.NewTMemoryBufferLen(len(arg1588))
		defer mbTrans1589.Close()
		_, err1590 := mbTrans1589.WriteString(arg1588)
		if err1590 != nil {
			Usage()
			return
		}
		factory1591 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1592 := factory1591.GetProtocol(mbTrans1589)
		argvalue1 := services.NewFromInfo()
		err1593 := argvalue1.Read(jsProt1592)
		if err1593 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.DeleteRemindingMsg(value0, value1))
		fmt.Print("\n")
		break
	case "deleteRemindingMsgByType":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "DeleteRemindingMsgByType requires 3 args")
			flag.Usage()
		}
		argvalue0, err1594 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1594 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg1595 := flag.Arg(2)
		mbTrans1596 := thrift.NewTMemoryBufferLen(len(arg1595))
		defer mbTrans1596.Close()
		_, err1597 := mbTrans1596.WriteString(arg1595)
		if err1597 != nil {
			Usage()
			return
		}
		factory1598 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1599 := factory1598.GetProtocol(mbTrans1596)
		containerStruct1 := services.NewDeleteRemindingMsgByTypeArgs()
		err1600 := containerStruct1.ReadField2(jsProt1599)
		if err1600 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.Types
		value1 := argvalue1
		arg1601 := flag.Arg(3)
		mbTrans1602 := thrift.NewTMemoryBufferLen(len(arg1601))
		defer mbTrans1602.Close()
		_, err1603 := mbTrans1602.WriteString(arg1601)
		if err1603 != nil {
			Usage()
			return
		}
		factory1604 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1605 := factory1604.GetProtocol(mbTrans1602)
		argvalue2 := services.NewFromInfo()
		err1606 := argvalue2.Read(jsProt1605)
		if err1606 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.DeleteRemindingMsgByType(value0, value1, value2))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
示例#7
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewUserManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "createUser":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "CreateUser requires 1 args")
			flag.Usage()
		}
		arg513 := flag.Arg(1)
		mbTrans514 := thrift.NewTMemoryBufferLen(len(arg513))
		defer mbTrans514.Close()
		_, err515 := mbTrans514.WriteString(arg513)
		if err515 != nil {
			Usage()
			return
		}
		factory516 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt517 := factory516.GetProtocol(mbTrans514)
		argvalue0 := services.NewUser()
		err518 := argvalue0.Read(jsProt517)
		if err518 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.CreateUser(value0))
		fmt.Print("\n")
		break
	case "updateUser":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "UpdateUser requires 3 args")
			flag.Usage()
		}
		arg519 := flag.Arg(1)
		mbTrans520 := thrift.NewTMemoryBufferLen(len(arg519))
		defer mbTrans520.Close()
		_, err521 := mbTrans520.WriteString(arg519)
		if err521 != nil {
			Usage()
			return
		}
		factory522 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt523 := factory522.GetProtocol(mbTrans520)
		argvalue0 := services.NewUser()
		err524 := argvalue0.Read(jsProt523)
		if err524 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err525 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err525 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg526 := flag.Arg(3)
		mbTrans527 := thrift.NewTMemoryBufferLen(len(arg526))
		defer mbTrans527.Close()
		_, err528 := mbTrans527.WriteString(arg526)
		if err528 != nil {
			Usage()
			return
		}
		factory529 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt530 := factory529.GetProtocol(mbTrans527)
		argvalue2 := services.NewFromInfo()
		err531 := argvalue2.Read(jsProt530)
		if err531 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.UpdateUser(value0, value1, value2))
		fmt.Print("\n")
		break
	case "setLoginTime":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "SetLoginTime requires 3 args")
			flag.Usage()
		}
		argvalue0, err532 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err532 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		arg534 := flag.Arg(3)
		mbTrans535 := thrift.NewTMemoryBufferLen(len(arg534))
		defer mbTrans535.Close()
		_, err536 := mbTrans535.WriteString(arg534)
		if err536 != nil {
			Usage()
			return
		}
		factory537 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt538 := factory537.GetProtocol(mbTrans535)
		argvalue2 := services.NewFromInfo()
		err539 := argvalue2.Read(jsProt538)
		if err539 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.SetLoginTime(value0, value1, value2))
		fmt.Print("\n")
		break
	case "setLogoutTime":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "SetLogoutTime requires 3 args")
			flag.Usage()
		}
		argvalue0, err540 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err540 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		arg542 := flag.Arg(3)
		mbTrans543 := thrift.NewTMemoryBufferLen(len(arg542))
		defer mbTrans543.Close()
		_, err544 := mbTrans543.WriteString(arg542)
		if err544 != nil {
			Usage()
			return
		}
		factory545 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt546 := factory545.GetProtocol(mbTrans543)
		argvalue2 := services.NewFromInfo()
		err547 := argvalue2.Read(jsProt546)
		if err547 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.SetLogoutTime(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getUserById":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetUserById requires 2 args")
			flag.Usage()
		}
		argvalue0, err548 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err548 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg549 := flag.Arg(2)
		mbTrans550 := thrift.NewTMemoryBufferLen(len(arg549))
		defer mbTrans550.Close()
		_, err551 := mbTrans550.WriteString(arg549)
		if err551 != nil {
			Usage()
			return
		}
		factory552 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt553 := factory552.GetProtocol(mbTrans550)
		argvalue1 := services.NewFromInfo()
		err554 := argvalue1.Read(jsProt553)
		if err554 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetUserById(value0, value1))
		fmt.Print("\n")
		break
	case "getUserByEmail":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetUserByEmail requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg556 := flag.Arg(2)
		mbTrans557 := thrift.NewTMemoryBufferLen(len(arg556))
		defer mbTrans557.Close()
		_, err558 := mbTrans557.WriteString(arg556)
		if err558 != nil {
			Usage()
			return
		}
		factory559 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt560 := factory559.GetProtocol(mbTrans557)
		argvalue1 := services.NewFromInfo()
		err561 := argvalue1.Read(jsProt560)
		if err561 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetUserByEmail(value0, value1))
		fmt.Print("\n")
		break
	case "getUserByPhone":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetUserByPhone requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg563 := flag.Arg(2)
		mbTrans564 := thrift.NewTMemoryBufferLen(len(arg563))
		defer mbTrans564.Close()
		_, err565 := mbTrans564.WriteString(arg563)
		if err565 != nil {
			Usage()
			return
		}
		factory566 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt567 := factory566.GetProtocol(mbTrans564)
		argvalue1 := services.NewFromInfo()
		err568 := argvalue1.Read(jsProt567)
		if err568 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetUserByPhone(value0, value1))
		fmt.Print("\n")
		break
	case "inviteUserByPhone":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "InviteUserByPhone requires 3 args")
			flag.Usage()
		}
		argvalue0, err569 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err569 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		arg571 := flag.Arg(3)
		mbTrans572 := thrift.NewTMemoryBufferLen(len(arg571))
		defer mbTrans572.Close()
		_, err573 := mbTrans572.WriteString(arg571)
		if err573 != nil {
			Usage()
			return
		}
		factory574 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt575 := factory574.GetProtocol(mbTrans572)
		argvalue2 := services.NewFromInfo()
		err576 := argvalue2.Read(jsProt575)
		if err576 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.InviteUserByPhone(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getUsersByPhones":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetUsersByPhones requires 2 args")
			flag.Usage()
		}
		arg577 := flag.Arg(1)
		mbTrans578 := thrift.NewTMemoryBufferLen(len(arg577))
		defer mbTrans578.Close()
		_, err579 := mbTrans578.WriteString(arg577)
		if err579 != nil {
			Usage()
			return
		}
		factory580 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt581 := factory580.GetProtocol(mbTrans578)
		containerStruct0 := services.NewGetUsersByPhonesArgs()
		err582 := containerStruct0.ReadField1(jsProt581)
		if err582 != nil {
			Usage()
			return
		}
		argvalue0 := containerStruct0.Phones
		value0 := argvalue0
		arg583 := flag.Arg(2)
		mbTrans584 := thrift.NewTMemoryBufferLen(len(arg583))
		defer mbTrans584.Close()
		_, err585 := mbTrans584.WriteString(arg583)
		if err585 != nil {
			Usage()
			return
		}
		factory586 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt587 := factory586.GetProtocol(mbTrans584)
		argvalue1 := services.NewFromInfo()
		err588 := argvalue1.Read(jsProt587)
		if err588 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetUsersByPhones(value0, value1))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewInviteCodeManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "createInviteCode":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "CreateInviteCode requires 3 args")
			flag.Usage()
		}
		argvalue0, err1617 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1617 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.InviteCodeType(tmp1)
		value1 := argvalue1
		arg1618 := flag.Arg(3)
		mbTrans1619 := thrift.NewTMemoryBufferLen(len(arg1618))
		defer mbTrans1619.Close()
		_, err1620 := mbTrans1619.WriteString(arg1618)
		if err1620 != nil {
			Usage()
			return
		}
		factory1621 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1622 := factory1621.GetProtocol(mbTrans1619)
		argvalue2 := services.NewFromInfo()
		err1623 := argvalue2.Read(jsProt1622)
		if err1623 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.CreateInviteCode(value0, value1, value2))
		fmt.Print("\n")
		break
	case "useInviteCode":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "UseInviteCode requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err1625 := (strconv.Atoi(flag.Arg(2)))
		if err1625 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		arg1626 := flag.Arg(3)
		mbTrans1627 := thrift.NewTMemoryBufferLen(len(arg1626))
		defer mbTrans1627.Close()
		_, err1628 := mbTrans1627.WriteString(arg1626)
		if err1628 != nil {
			Usage()
			return
		}
		factory1629 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1630 := factory1629.GetProtocol(mbTrans1627)
		argvalue2 := services.NewFromInfo()
		err1631 := argvalue2.Read(jsProt1630)
		if err1631 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.UseInviteCode(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getInviteCodeInfo":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetInviteCodeInfo requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg1633 := flag.Arg(2)
		mbTrans1634 := thrift.NewTMemoryBufferLen(len(arg1633))
		defer mbTrans1634.Close()
		_, err1635 := mbTrans1634.WriteString(arg1633)
		if err1635 != nil {
			Usage()
			return
		}
		factory1636 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1637 := factory1636.GetProtocol(mbTrans1634)
		argvalue1 := services.NewFromInfo()
		err1638 := argvalue1.Read(jsProt1637)
		if err1638 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetInviteCodeInfo(value0, value1))
		fmt.Print("\n")
		break
	case "updateInviteCodeInfo":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "UpdateInviteCodeInfo requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		arg1641 := flag.Arg(3)
		mbTrans1642 := thrift.NewTMemoryBufferLen(len(arg1641))
		defer mbTrans1642.Close()
		_, err1643 := mbTrans1642.WriteString(arg1641)
		if err1643 != nil {
			Usage()
			return
		}
		factory1644 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1645 := factory1644.GetProtocol(mbTrans1642)
		argvalue2 := services.NewFromInfo()
		err1646 := argvalue2.Read(jsProt1645)
		if err1646 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.UpdateInviteCodeInfo(value0, value1, value2))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
示例#9
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewGroupManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "createGroup":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "CreateGroup requires 3 args")
			flag.Usage()
		}
		arg189 := flag.Arg(1)
		mbTrans190 := thrift.NewTMemoryBufferLen(len(arg189))
		defer mbTrans190.Close()
		_, err191 := mbTrans190.WriteString(arg189)
		if err191 != nil {
			Usage()
			return
		}
		factory192 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt193 := factory192.GetProtocol(mbTrans190)
		argvalue0 := services.NewGroup()
		err194 := argvalue0.Read(jsProt193)
		if err194 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg195 := flag.Arg(2)
		mbTrans196 := thrift.NewTMemoryBufferLen(len(arg195))
		defer mbTrans196.Close()
		_, err197 := mbTrans196.WriteString(arg195)
		if err197 != nil {
			Usage()
			return
		}
		factory198 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt199 := factory198.GetProtocol(mbTrans196)
		containerStruct1 := services.NewCreateGroupArgs()
		err200 := containerStruct1.ReadField2(jsProt199)
		if err200 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.FriendUidList
		value1 := argvalue1
		arg201 := flag.Arg(3)
		mbTrans202 := thrift.NewTMemoryBufferLen(len(arg201))
		defer mbTrans202.Close()
		_, err203 := mbTrans202.WriteString(arg201)
		if err203 != nil {
			Usage()
			return
		}
		factory204 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt205 := factory204.GetProtocol(mbTrans202)
		argvalue2 := services.NewFromInfo()
		err206 := argvalue2.Read(jsProt205)
		if err206 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.CreateGroup(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getGroup":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetGroup requires 2 args")
			flag.Usage()
		}
		argvalue0, err207 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err207 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg208 := flag.Arg(2)
		mbTrans209 := thrift.NewTMemoryBufferLen(len(arg208))
		defer mbTrans209.Close()
		_, err210 := mbTrans209.WriteString(arg208)
		if err210 != nil {
			Usage()
			return
		}
		factory211 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt212 := factory211.GetProtocol(mbTrans209)
		argvalue1 := services.NewFromInfo()
		err213 := argvalue1.Read(jsProt212)
		if err213 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetGroup(value0, value1))
		fmt.Print("\n")
		break
	case "updateGroup":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "UpdateGroup requires 3 args")
			flag.Usage()
		}
		arg214 := flag.Arg(1)
		mbTrans215 := thrift.NewTMemoryBufferLen(len(arg214))
		defer mbTrans215.Close()
		_, err216 := mbTrans215.WriteString(arg214)
		if err216 != nil {
			Usage()
			return
		}
		factory217 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt218 := factory217.GetProtocol(mbTrans215)
		argvalue0 := services.NewGroup()
		err219 := argvalue0.Read(jsProt218)
		if err219 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err220 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err220 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg221 := flag.Arg(3)
		mbTrans222 := thrift.NewTMemoryBufferLen(len(arg221))
		defer mbTrans222.Close()
		_, err223 := mbTrans222.WriteString(arg221)
		if err223 != nil {
			Usage()
			return
		}
		factory224 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt225 := factory224.GetProtocol(mbTrans222)
		argvalue2 := services.NewFromInfo()
		err226 := argvalue2.Read(jsProt225)
		if err226 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.UpdateGroup(value0, value1, value2))
		fmt.Print("\n")
		break
	case "updateTrackedGroup":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "UpdateTrackedGroup requires 3 args")
			flag.Usage()
		}
		arg227 := flag.Arg(1)
		mbTrans228 := thrift.NewTMemoryBufferLen(len(arg227))
		defer mbTrans228.Close()
		_, err229 := mbTrans228.WriteString(arg227)
		if err229 != nil {
			Usage()
			return
		}
		factory230 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt231 := factory230.GetProtocol(mbTrans228)
		argvalue0 := services.NewTrackedGroup()
		err232 := argvalue0.Read(jsProt231)
		if err232 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err233 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err233 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg234 := flag.Arg(3)
		mbTrans235 := thrift.NewTMemoryBufferLen(len(arg234))
		defer mbTrans235.Close()
		_, err236 := mbTrans235.WriteString(arg234)
		if err236 != nil {
			Usage()
			return
		}
		factory237 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt238 := factory237.GetProtocol(mbTrans235)
		argvalue2 := services.NewFromInfo()
		err239 := argvalue2.Read(jsProt238)
		if err239 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.UpdateTrackedGroup(value0, value1, value2))
		fmt.Print("\n")
		break
	case "deleteGroup":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "DeleteGroup requires 3 args")
			flag.Usage()
		}
		argvalue0, err240 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err240 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err241 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err241 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg242 := flag.Arg(3)
		mbTrans243 := thrift.NewTMemoryBufferLen(len(arg242))
		defer mbTrans243.Close()
		_, err244 := mbTrans243.WriteString(arg242)
		if err244 != nil {
			Usage()
			return
		}
		factory245 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt246 := factory245.GetProtocol(mbTrans243)
		argvalue2 := services.NewFromInfo()
		err247 := argvalue2.Read(jsProt246)
		if err247 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.DeleteGroup(value0, value1, value2))
		fmt.Print("\n")
		break
	case "trackGroup":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "TrackGroup requires 4 args")
			flag.Usage()
		}
		argvalue0, err248 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err248 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err249 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err249 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2 := flag.Arg(3) == "true"
		value2 := argvalue2
		arg251 := flag.Arg(4)
		mbTrans252 := thrift.NewTMemoryBufferLen(len(arg251))
		defer mbTrans252.Close()
		_, err253 := mbTrans252.WriteString(arg251)
		if err253 != nil {
			Usage()
			return
		}
		factory254 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt255 := factory254.GetProtocol(mbTrans252)
		argvalue3 := services.NewFromInfo()
		err256 := argvalue3.Read(jsProt255)
		if err256 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.TrackGroup(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "hasTrackedGroup":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "HasTrackedGroup requires 3 args")
			flag.Usage()
		}
		argvalue0, err257 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err257 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err258 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err258 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg259 := flag.Arg(3)
		mbTrans260 := thrift.NewTMemoryBufferLen(len(arg259))
		defer mbTrans260.Close()
		_, err261 := mbTrans260.WriteString(arg259)
		if err261 != nil {
			Usage()
			return
		}
		factory262 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt263 := factory262.GetProtocol(mbTrans260)
		argvalue2 := services.NewFromInfo()
		err264 := argvalue2.Read(jsProt263)
		if err264 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.HasTrackedGroup(value0, value1, value2))
		fmt.Print("\n")
		break
	case "operateGroupMember":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "OperateGroupMember requires 6 args")
			flag.Usage()
		}
		tmp0, err := (strconv.Atoi(flag.Arg(1)))
		if err != nil {
			Usage()
			return
		}
		argvalue0 := services.MemberType(tmp0)
		value0 := argvalue0
		argvalue1, err265 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err265 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg266 := flag.Arg(3)
		mbTrans267 := thrift.NewTMemoryBufferLen(len(arg266))
		defer mbTrans267.Close()
		_, err268 := mbTrans267.WriteString(arg266)
		if err268 != nil {
			Usage()
			return
		}
		factory269 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt270 := factory269.GetProtocol(mbTrans267)
		containerStruct2 := services.NewOperateGroupMemberArgs()
		err271 := containerStruct2.ReadField3(jsProt270)
		if err271 != nil {
			Usage()
			return
		}
		argvalue2 := containerStruct2.OperandUidList
		value2 := argvalue2
		argvalue3, err272 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err272 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4 := flag.Arg(5) == "true"
		value4 := argvalue4
		arg274 := flag.Arg(6)
		mbTrans275 := thrift.NewTMemoryBufferLen(len(arg274))
		defer mbTrans275.Close()
		_, err276 := mbTrans275.WriteString(arg274)
		if err276 != nil {
			Usage()
			return
		}
		factory277 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt278 := factory277.GetProtocol(mbTrans275)
		argvalue5 := services.NewFromInfo()
		err279 := argvalue5.Read(jsProt278)
		if err279 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.OperateGroupMember(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "getGroupMembers":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetGroupMembers requires 2 args")
			flag.Usage()
		}
		argvalue0, err280 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err280 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg281 := flag.Arg(2)
		mbTrans282 := thrift.NewTMemoryBufferLen(len(arg281))
		defer mbTrans282.Close()
		_, err283 := mbTrans282.WriteString(arg281)
		if err283 != nil {
			Usage()
			return
		}
		factory284 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt285 := factory284.GetProtocol(mbTrans282)
		argvalue1 := services.NewFromInfo()
		err286 := argvalue1.Read(jsProt285)
		if err286 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetGroupMembers(value0, value1))
		fmt.Print("\n")
		break
	case "getGroupTrackers":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "GetGroupTrackers requires 7 args")
			flag.Usage()
		}
		argvalue0, err287 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err287 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err288 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err288 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err289 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err289 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err290 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err290 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4 := flag.Arg(5) == "true"
		value4 := argvalue4
		tmp5, err292 := (strconv.Atoi(flag.Arg(6)))
		if err292 != nil {
			Usage()
			return
		}
		argvalue5 := int32(tmp5)
		value5 := argvalue5
		arg293 := flag.Arg(7)
		mbTrans294 := thrift.NewTMemoryBufferLen(len(arg293))
		defer mbTrans294.Close()
		_, err295 := mbTrans294.WriteString(arg293)
		if err295 != nil {
			Usage()
			return
		}
		factory296 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt297 := factory296.GetProtocol(mbTrans294)
		argvalue6 := services.NewFromInfo()
		err298 := argvalue6.Read(jsProt297)
		if err298 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.GetGroupTrackers(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "getOwnedGroups":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "GetOwnedGroups requires 5 args")
			flag.Usage()
		}
		argvalue0, err299 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err299 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err300 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err300 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err301 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err301 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		tmp3, err302 := (strconv.Atoi(flag.Arg(4)))
		if err302 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		arg303 := flag.Arg(5)
		mbTrans304 := thrift.NewTMemoryBufferLen(len(arg303))
		defer mbTrans304.Close()
		_, err305 := mbTrans304.WriteString(arg303)
		if err305 != nil {
			Usage()
			return
		}
		factory306 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt307 := factory306.GetProtocol(mbTrans304)
		argvalue4 := services.NewFromInfo()
		err308 := argvalue4.Read(jsProt307)
		if err308 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.GetOwnedGroups(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "getJoinedGroups":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "GetJoinedGroups requires 4 args")
			flag.Usage()
		}
		argvalue0, err309 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err309 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err310 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err310 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err311 := (strconv.Atoi(flag.Arg(3)))
		if err311 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		arg312 := flag.Arg(4)
		mbTrans313 := thrift.NewTMemoryBufferLen(len(arg312))
		defer mbTrans313.Close()
		_, err314 := mbTrans313.WriteString(arg312)
		if err314 != nil {
			Usage()
			return
		}
		factory315 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt316 := factory315.GetProtocol(mbTrans313)
		argvalue3 := services.NewFromInfo()
		err317 := argvalue3.Read(jsProt316)
		if err317 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.GetJoinedGroups(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getTrackedGroups":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "GetTrackedGroups requires 7 args")
			flag.Usage()
		}
		argvalue0, err318 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err318 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err319 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err319 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err320 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err320 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err321 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err321 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4 := flag.Arg(5) == "true"
		value4 := argvalue4
		tmp5, err323 := (strconv.Atoi(flag.Arg(6)))
		if err323 != nil {
			Usage()
			return
		}
		argvalue5 := int32(tmp5)
		value5 := argvalue5
		arg324 := flag.Arg(7)
		mbTrans325 := thrift.NewTMemoryBufferLen(len(arg324))
		defer mbTrans325.Close()
		_, err326 := mbTrans325.WriteString(arg324)
		if err326 != nil {
			Usage()
			return
		}
		factory327 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt328 := factory327.GetProtocol(mbTrans325)
		argvalue6 := services.NewFromInfo()
		err329 := argvalue6.Read(jsProt328)
		if err329 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.GetTrackedGroups(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "blockGroupUser":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "BlockGroupUser requires 6 args")
			flag.Usage()
		}
		argvalue0, err330 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err330 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg331 := flag.Arg(2)
		mbTrans332 := thrift.NewTMemoryBufferLen(len(arg331))
		defer mbTrans332.Close()
		_, err333 := mbTrans332.WriteString(arg331)
		if err333 != nil {
			Usage()
			return
		}
		factory334 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt335 := factory334.GetProtocol(mbTrans332)
		containerStruct1 := services.NewBlockGroupUserArgs()
		err336 := containerStruct1.ReadField2(jsProt335)
		if err336 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.BlockUsers
		value1 := argvalue1
		argvalue2, err337 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err337 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3 := flag.Arg(4) == "true"
		value3 := argvalue3
		tmp4, err := (strconv.Atoi(flag.Arg(5)))
		if err != nil {
			Usage()
			return
		}
		argvalue4 := services.Zone(tmp4)
		value4 := argvalue4
		arg339 := flag.Arg(6)
		mbTrans340 := thrift.NewTMemoryBufferLen(len(arg339))
		defer mbTrans340.Close()
		_, err341 := mbTrans340.WriteString(arg339)
		if err341 != nil {
			Usage()
			return
		}
		factory342 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt343 := factory342.GetProtocol(mbTrans340)
		argvalue5 := services.NewFromInfo()
		err344 := argvalue5.Read(jsProt343)
		if err344 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.BlockGroupUser(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "getGroupUserBlockList":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetGroupUserBlockList requires 2 args")
			flag.Usage()
		}
		argvalue0, err345 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err345 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg346 := flag.Arg(2)
		mbTrans347 := thrift.NewTMemoryBufferLen(len(arg346))
		defer mbTrans347.Close()
		_, err348 := mbTrans347.WriteString(arg346)
		if err348 != nil {
			Usage()
			return
		}
		factory349 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt350 := factory349.GetProtocol(mbTrans347)
		argvalue1 := services.NewFromInfo()
		err351 := argvalue1.Read(jsProt350)
		if err351 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetGroupUserBlockList(value0, value1))
		fmt.Print("\n")
		break
	case "updateGroupMember":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "UpdateGroupMember requires 5 args")
			flag.Usage()
		}
		argvalue0, err352 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err352 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err353 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err353 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.MemberType(tmp3)
		value3 := argvalue3
		arg355 := flag.Arg(5)
		mbTrans356 := thrift.NewTMemoryBufferLen(len(arg355))
		defer mbTrans356.Close()
		_, err357 := mbTrans356.WriteString(arg355)
		if err357 != nil {
			Usage()
			return
		}
		factory358 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt359 := factory358.GetProtocol(mbTrans356)
		argvalue4 := services.NewFromInfo()
		err360 := argvalue4.Read(jsProt359)
		if err360 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.UpdateGroupMember(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "groupOwnerLeave":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "GroupOwnerLeave requires 3 args")
			flag.Usage()
		}
		argvalue0, err361 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err361 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err362 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err362 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg363 := flag.Arg(3)
		mbTrans364 := thrift.NewTMemoryBufferLen(len(arg363))
		defer mbTrans364.Close()
		_, err365 := mbTrans364.WriteString(arg363)
		if err365 != nil {
			Usage()
			return
		}
		factory366 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt367 := factory366.GetProtocol(mbTrans364)
		argvalue2 := services.NewFromInfo()
		err368 := argvalue2.Read(jsProt367)
		if err368 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.GroupOwnerLeave(value0, value1, value2))
		fmt.Print("\n")
		break
	case "setGroupNoDisturbing":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "SetGroupNoDisturbing requires 4 args")
			flag.Usage()
		}
		argvalue0, err369 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err369 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err370 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err370 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2 := flag.Arg(3) == "true"
		value2 := argvalue2
		arg372 := flag.Arg(4)
		mbTrans373 := thrift.NewTMemoryBufferLen(len(arg372))
		defer mbTrans373.Close()
		_, err374 := mbTrans373.WriteString(arg372)
		if err374 != nil {
			Usage()
			return
		}
		factory375 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt376 := factory375.GetProtocol(mbTrans373)
		argvalue3 := services.NewFromInfo()
		err377 := argvalue3.Read(jsProt376)
		if err377 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.SetGroupNoDisturbing(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getUserGroups":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetUserGroups requires 2 args")
			flag.Usage()
		}
		argvalue0, err378 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err378 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg379 := flag.Arg(2)
		mbTrans380 := thrift.NewTMemoryBufferLen(len(arg379))
		defer mbTrans380.Close()
		_, err381 := mbTrans380.WriteString(arg379)
		if err381 != nil {
			Usage()
			return
		}
		factory382 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt383 := factory382.GetProtocol(mbTrans380)
		argvalue1 := services.NewFromInfo()
		err384 := argvalue1.Read(jsProt383)
		if err384 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetUserGroups(value0, value1))
		fmt.Print("\n")
		break
	case "getGroupCloudSize":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetGroupCloudSize requires 2 args")
			flag.Usage()
		}
		argvalue0, err385 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err385 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg386 := flag.Arg(2)
		mbTrans387 := thrift.NewTMemoryBufferLen(len(arg386))
		defer mbTrans387.Close()
		_, err388 := mbTrans387.WriteString(arg386)
		if err388 != nil {
			Usage()
			return
		}
		factory389 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt390 := factory389.GetProtocol(mbTrans387)
		argvalue1 := services.NewFromInfo()
		err391 := argvalue1.Read(jsProt390)
		if err391 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetGroupCloudSize(value0, value1))
		fmt.Print("\n")
		break
	case "addUpGroupResourceSize":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "AddUpGroupResourceSize requires 2 args")
			flag.Usage()
		}
		argvalue0, err392 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err392 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg393 := flag.Arg(2)
		mbTrans394 := thrift.NewTMemoryBufferLen(len(arg393))
		defer mbTrans394.Close()
		_, err395 := mbTrans394.WriteString(arg393)
		if err395 != nil {
			Usage()
			return
		}
		factory396 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt397 := factory396.GetProtocol(mbTrans394)
		argvalue1 := services.NewFromInfo()
		err398 := argvalue1.Read(jsProt397)
		if err398 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.AddUpGroupResourceSize(value0, value1))
		fmt.Print("\n")
		break
	case "getUserGroupRelations":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "GetUserGroupRelations requires 3 args")
			flag.Usage()
		}
		argvalue0, err399 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err399 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg400 := flag.Arg(2)
		mbTrans401 := thrift.NewTMemoryBufferLen(len(arg400))
		defer mbTrans401.Close()
		_, err402 := mbTrans401.WriteString(arg400)
		if err402 != nil {
			Usage()
			return
		}
		factory403 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt404 := factory403.GetProtocol(mbTrans401)
		containerStruct1 := services.NewGetUserGroupRelationsArgs()
		err405 := containerStruct1.ReadField2(jsProt404)
		if err405 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.Gids
		value1 := argvalue1
		arg406 := flag.Arg(3)
		mbTrans407 := thrift.NewTMemoryBufferLen(len(arg406))
		defer mbTrans407.Close()
		_, err408 := mbTrans407.WriteString(arg406)
		if err408 != nil {
			Usage()
			return
		}
		factory409 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt410 := factory409.GetProtocol(mbTrans407)
		argvalue2 := services.NewFromInfo()
		err411 := argvalue2.Read(jsProt410)
		if err411 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.GetUserGroupRelations(value0, value1, value2))
		fmt.Print("\n")
		break
	case "updateGroupToPrivate":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UpdateGroupToPrivate requires 2 args")
			flag.Usage()
		}
		argvalue0, err412 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err412 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg413 := flag.Arg(2)
		mbTrans414 := thrift.NewTMemoryBufferLen(len(arg413))
		defer mbTrans414.Close()
		_, err415 := mbTrans414.WriteString(arg413)
		if err415 != nil {
			Usage()
			return
		}
		factory416 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt417 := factory416.GetProtocol(mbTrans414)
		argvalue1 := services.NewFromInfo()
		err418 := argvalue1.Read(jsProt417)
		if err418 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UpdateGroupToPrivate(value0, value1))
		fmt.Print("\n")
		break
	case "updateGroupNoSpeakingList":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "UpdateGroupNoSpeakingList requires 4 args")
			flag.Usage()
		}
		argvalue0, err419 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err419 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg420 := flag.Arg(2)
		mbTrans421 := thrift.NewTMemoryBufferLen(len(arg420))
		defer mbTrans421.Close()
		_, err422 := mbTrans421.WriteString(arg420)
		if err422 != nil {
			Usage()
			return
		}
		factory423 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt424 := factory423.GetProtocol(mbTrans421)
		containerStruct1 := services.NewUpdateGroupNoSpeakingListArgs()
		err425 := containerStruct1.ReadField2(jsProt424)
		if err425 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.SpeakingList
		value1 := argvalue1
		arg426 := flag.Arg(3)
		mbTrans427 := thrift.NewTMemoryBufferLen(len(arg426))
		defer mbTrans427.Close()
		_, err428 := mbTrans427.WriteString(arg426)
		if err428 != nil {
			Usage()
			return
		}
		factory429 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt430 := factory429.GetProtocol(mbTrans427)
		containerStruct2 := services.NewUpdateGroupNoSpeakingListArgs()
		err431 := containerStruct2.ReadField3(jsProt430)
		if err431 != nil {
			Usage()
			return
		}
		argvalue2 := containerStruct2.NoSpeakingList
		value2 := argvalue2
		arg432 := flag.Arg(4)
		mbTrans433 := thrift.NewTMemoryBufferLen(len(arg432))
		defer mbTrans433.Close()
		_, err434 := mbTrans433.WriteString(arg432)
		if err434 != nil {
			Usage()
			return
		}
		factory435 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt436 := factory435.GetProtocol(mbTrans433)
		argvalue3 := services.NewFromInfo()
		err437 := argvalue3.Read(jsProt436)
		if err437 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.UpdateGroupNoSpeakingList(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "enableGroupNoSpeakingList":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "EnableGroupNoSpeakingList requires 3 args")
			flag.Usage()
		}
		argvalue0, err438 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err438 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1 := flag.Arg(2) == "true"
		value1 := argvalue1
		arg440 := flag.Arg(3)
		mbTrans441 := thrift.NewTMemoryBufferLen(len(arg440))
		defer mbTrans441.Close()
		_, err442 := mbTrans441.WriteString(arg440)
		if err442 != nil {
			Usage()
			return
		}
		factory443 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt444 := factory443.GetProtocol(mbTrans441)
		argvalue2 := services.NewFromInfo()
		err445 := argvalue2.Read(jsProt444)
		if err445 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.EnableGroupNoSpeakingList(value0, value1, value2))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
示例#10
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewChatManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "getChatHistoryMessages":
		if flag.NArg()-1 != 9 {
			fmt.Fprintln(os.Stderr, "GetChatHistoryMessages requires 9 args")
			flag.Usage()
		}
		argvalue0, err22 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err22 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err23 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err23 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err24 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err24 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err25 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err25 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err26 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err26 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5, err27 := (strconv.ParseInt(flag.Arg(6), 10, 64))
		if err27 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		argvalue6 := flag.Arg(7) == "true"
		value6 := argvalue6
		tmp7, err29 := (strconv.Atoi(flag.Arg(8)))
		if err29 != nil {
			Usage()
			return
		}
		argvalue7 := int32(tmp7)
		value7 := argvalue7
		arg30 := flag.Arg(9)
		mbTrans31 := thrift.NewTMemoryBufferLen(len(arg30))
		defer mbTrans31.Close()
		_, err32 := mbTrans31.WriteString(arg30)
		if err32 != nil {
			Usage()
			return
		}
		factory33 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt34 := factory33.GetProtocol(mbTrans31)
		argvalue8 := services.NewFromInfo()
		err35 := argvalue8.Read(jsProt34)
		if err35 != nil {
			Usage()
			return
		}
		value8 := argvalue8
		fmt.Print(client.GetChatHistoryMessages(value0, value1, value2, value3, value4, value5, value6, value7, value8))
		fmt.Print("\n")
		break
	case "sendChatMessage":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "SendChatMessage requires 2 args")
			flag.Usage()
		}
		arg36 := flag.Arg(1)
		mbTrans37 := thrift.NewTMemoryBufferLen(len(arg36))
		defer mbTrans37.Close()
		_, err38 := mbTrans37.WriteString(arg36)
		if err38 != nil {
			Usage()
			return
		}
		factory39 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt40 := factory39.GetProtocol(mbTrans37)
		argvalue0 := services.NewChatMessage()
		err41 := argvalue0.Read(jsProt40)
		if err41 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg42 := flag.Arg(2)
		mbTrans43 := thrift.NewTMemoryBufferLen(len(arg42))
		defer mbTrans43.Close()
		_, err44 := mbTrans43.WriteString(arg42)
		if err44 != nil {
			Usage()
			return
		}
		factory45 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt46 := factory45.GetProtocol(mbTrans43)
		argvalue1 := services.NewFromInfo()
		err47 := argvalue1.Read(jsProt46)
		if err47 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.SendChatMessage(value0, value1))
		fmt.Print("\n")
		break
	case "updateChatMessage":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "UpdateChatMessage requires 3 args")
			flag.Usage()
		}
		arg48 := flag.Arg(1)
		mbTrans49 := thrift.NewTMemoryBufferLen(len(arg48))
		defer mbTrans49.Close()
		_, err50 := mbTrans49.WriteString(arg48)
		if err50 != nil {
			Usage()
			return
		}
		factory51 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt52 := factory51.GetProtocol(mbTrans49)
		containerStruct0 := services.NewUpdateChatMessageArgs()
		err53 := containerStruct0.ReadField1(jsProt52)
		if err53 != nil {
			Usage()
			return
		}
		argvalue0 := containerStruct0.UpdateChatMessages
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.ChatMessageOperation(tmp1)
		value1 := argvalue1
		arg54 := flag.Arg(3)
		mbTrans55 := thrift.NewTMemoryBufferLen(len(arg54))
		defer mbTrans55.Close()
		_, err56 := mbTrans55.WriteString(arg54)
		if err56 != nil {
			Usage()
			return
		}
		factory57 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt58 := factory57.GetProtocol(mbTrans55)
		argvalue2 := services.NewFromInfo()
		err59 := argvalue2.Read(jsProt58)
		if err59 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.UpdateChatMessage(value0, value1, value2))
		fmt.Print("\n")
		break
	case "sendMessage2Members":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "SendMessage2Members requires 3 args")
			flag.Usage()
		}
		argvalue0, err60 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err60 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg61 := flag.Arg(2)
		mbTrans62 := thrift.NewTMemoryBufferLen(len(arg61))
		defer mbTrans62.Close()
		_, err63 := mbTrans62.WriteString(arg61)
		if err63 != nil {
			Usage()
			return
		}
		factory64 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt65 := factory64.GetProtocol(mbTrans62)
		argvalue1 := services.NewChatMessage()
		err66 := argvalue1.Read(jsProt65)
		if err66 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg67 := flag.Arg(3)
		mbTrans68 := thrift.NewTMemoryBufferLen(len(arg67))
		defer mbTrans68.Close()
		_, err69 := mbTrans68.WriteString(arg67)
		if err69 != nil {
			Usage()
			return
		}
		factory70 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt71 := factory70.GetProtocol(mbTrans68)
		argvalue2 := services.NewFromInfo()
		err72 := argvalue2.Read(jsProt71)
		if err72 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.SendMessage2Members(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getUnreadMessage":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "GetUnreadMessage requires 3 args")
			flag.Usage()
		}
		arg73 := flag.Arg(1)
		mbTrans74 := thrift.NewTMemoryBufferLen(len(arg73))
		defer mbTrans74.Close()
		_, err75 := mbTrans74.WriteString(arg73)
		if err75 != nil {
			Usage()
			return
		}
		factory76 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt77 := factory76.GetProtocol(mbTrans74)
		containerStruct0 := services.NewGetUnreadMessageArgs()
		err78 := containerStruct0.ReadField1(jsProt77)
		if err78 != nil {
			Usage()
			return
		}
		argvalue0 := containerStruct0.MsgQueryList
		value0 := argvalue0
		argvalue1, err79 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err79 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg80 := flag.Arg(3)
		mbTrans81 := thrift.NewTMemoryBufferLen(len(arg80))
		defer mbTrans81.Close()
		_, err82 := mbTrans81.WriteString(arg80)
		if err82 != nil {
			Usage()
			return
		}
		factory83 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt84 := factory83.GetProtocol(mbTrans81)
		argvalue2 := services.NewFromInfo()
		err85 := argvalue2.Read(jsProt84)
		if err85 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.GetUnreadMessage(value0, value1, value2))
		fmt.Print("\n")
		break
	case "undoPrivateGroupMessage":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UndoPrivateGroupMessage requires 2 args")
			flag.Usage()
		}
		arg86 := flag.Arg(1)
		mbTrans87 := thrift.NewTMemoryBufferLen(len(arg86))
		defer mbTrans87.Close()
		_, err88 := mbTrans87.WriteString(arg86)
		if err88 != nil {
			Usage()
			return
		}
		factory89 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt90 := factory89.GetProtocol(mbTrans87)
		argvalue0 := services.NewChatMessage()
		err91 := argvalue0.Read(jsProt90)
		if err91 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg92 := flag.Arg(2)
		mbTrans93 := thrift.NewTMemoryBufferLen(len(arg92))
		defer mbTrans93.Close()
		_, err94 := mbTrans93.WriteString(arg92)
		if err94 != nil {
			Usage()
			return
		}
		factory95 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt96 := factory95.GetProtocol(mbTrans93)
		argvalue1 := services.NewFromInfo()
		err97 := argvalue1.Read(jsProt96)
		if err97 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UndoPrivateGroupMessage(value0, value1))
		fmt.Print("\n")
		break
	case "undoChatMessage":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UndoChatMessage requires 2 args")
			flag.Usage()
		}
		arg98 := flag.Arg(1)
		mbTrans99 := thrift.NewTMemoryBufferLen(len(arg98))
		defer mbTrans99.Close()
		_, err100 := mbTrans99.WriteString(arg98)
		if err100 != nil {
			Usage()
			return
		}
		factory101 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt102 := factory101.GetProtocol(mbTrans99)
		argvalue0 := services.NewChatMessage()
		err103 := argvalue0.Read(jsProt102)
		if err103 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg104 := flag.Arg(2)
		mbTrans105 := thrift.NewTMemoryBufferLen(len(arg104))
		defer mbTrans105.Close()
		_, err106 := mbTrans105.WriteString(arg104)
		if err106 != nil {
			Usage()
			return
		}
		factory107 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt108 := factory107.GetProtocol(mbTrans105)
		argvalue1 := services.NewFromInfo()
		err109 := argvalue1.Read(jsProt108)
		if err109 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UndoChatMessage(value0, value1))
		fmt.Print("\n")
		break
	case "deletePersonalChatMessage":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "DeletePersonalChatMessage requires 2 args")
			flag.Usage()
		}
		arg110 := flag.Arg(1)
		mbTrans111 := thrift.NewTMemoryBufferLen(len(arg110))
		defer mbTrans111.Close()
		_, err112 := mbTrans111.WriteString(arg110)
		if err112 != nil {
			Usage()
			return
		}
		factory113 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt114 := factory113.GetProtocol(mbTrans111)
		argvalue0 := services.NewChatMessage()
		err115 := argvalue0.Read(jsProt114)
		if err115 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg116 := flag.Arg(2)
		mbTrans117 := thrift.NewTMemoryBufferLen(len(arg116))
		defer mbTrans117.Close()
		_, err118 := mbTrans117.WriteString(arg116)
		if err118 != nil {
			Usage()
			return
		}
		factory119 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt120 := factory119.GetProtocol(mbTrans117)
		argvalue1 := services.NewFromInfo()
		err121 := argvalue1.Read(jsProt120)
		if err121 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.DeletePersonalChatMessage(value0, value1))
		fmt.Print("\n")
		break
	case "clearPersonalChatMessage":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "ClearPersonalChatMessage requires 4 args")
			flag.Usage()
		}
		argvalue0, err122 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err122 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err123 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err123 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err124 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err124 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		arg125 := flag.Arg(4)
		mbTrans126 := thrift.NewTMemoryBufferLen(len(arg125))
		defer mbTrans126.Close()
		_, err127 := mbTrans126.WriteString(arg125)
		if err127 != nil {
			Usage()
			return
		}
		factory128 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt129 := factory128.GetProtocol(mbTrans126)
		argvalue3 := services.NewFromInfo()
		err130 := argvalue3.Read(jsProt129)
		if err130 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.ClearPersonalChatMessage(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
示例#11
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewFriendManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "findUserById":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "FindUserById requires 2 args")
			flag.Usage()
		}
		argvalue0, err956 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err956 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg957 := flag.Arg(2)
		mbTrans958 := thrift.NewTMemoryBufferLen(len(arg957))
		defer mbTrans958.Close()
		_, err959 := mbTrans958.WriteString(arg957)
		if err959 != nil {
			Usage()
			return
		}
		factory960 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt961 := factory960.GetProtocol(mbTrans958)
		argvalue1 := services.NewFromInfo()
		err962 := argvalue1.Read(jsProt961)
		if err962 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.FindUserById(value0, value1))
		fmt.Print("\n")
		break
	case "deleteFriend":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "DeleteFriend requires 3 args")
			flag.Usage()
		}
		argvalue0, err963 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err963 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err964 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err964 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg965 := flag.Arg(3)
		mbTrans966 := thrift.NewTMemoryBufferLen(len(arg965))
		defer mbTrans966.Close()
		_, err967 := mbTrans966.WriteString(arg965)
		if err967 != nil {
			Usage()
			return
		}
		factory968 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt969 := factory968.GetProtocol(mbTrans966)
		argvalue2 := services.NewFromInfo()
		err970 := argvalue2.Read(jsProt969)
		if err970 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.DeleteFriend(value0, value1, value2))
		fmt.Print("\n")
		break
	case "sendFriendReq":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "SendFriendReq requires 3 args")
			flag.Usage()
		}
		argvalue0, err971 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err971 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		arg973 := flag.Arg(3)
		mbTrans974 := thrift.NewTMemoryBufferLen(len(arg973))
		defer mbTrans974.Close()
		_, err975 := mbTrans974.WriteString(arg973)
		if err975 != nil {
			Usage()
			return
		}
		factory976 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt977 := factory976.GetProtocol(mbTrans974)
		argvalue2 := services.NewFromInfo()
		err978 := argvalue2.Read(jsProt977)
		if err978 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.SendFriendReq(value0, value1, value2))
		fmt.Print("\n")
		break
	case "sendFriendRes":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "SendFriendRes requires 4 args")
			flag.Usage()
		}
		argvalue0, err979 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err979 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err980 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err980 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2 := flag.Arg(3) == "true"
		value2 := argvalue2
		arg982 := flag.Arg(4)
		mbTrans983 := thrift.NewTMemoryBufferLen(len(arg982))
		defer mbTrans983.Close()
		_, err984 := mbTrans983.WriteString(arg982)
		if err984 != nil {
			Usage()
			return
		}
		factory985 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt986 := factory985.GetProtocol(mbTrans983)
		argvalue3 := services.NewFromInfo()
		err987 := argvalue3.Read(jsProt986)
		if err987 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.SendFriendRes(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getFriends":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetFriends requires 2 args")
			flag.Usage()
		}
		argvalue0, err988 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err988 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg989 := flag.Arg(2)
		mbTrans990 := thrift.NewTMemoryBufferLen(len(arg989))
		defer mbTrans990.Close()
		_, err991 := mbTrans990.WriteString(arg989)
		if err991 != nil {
			Usage()
			return
		}
		factory992 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt993 := factory992.GetProtocol(mbTrans990)
		argvalue1 := services.NewFromInfo()
		err994 := argvalue1.Read(jsProt993)
		if err994 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetFriends(value0, value1))
		fmt.Print("\n")
		break
	case "getFriendGroups":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "GetFriendGroups requires 3 args")
			flag.Usage()
		}
		argvalue0, err995 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err995 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err996 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err996 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg997 := flag.Arg(3)
		mbTrans998 := thrift.NewTMemoryBufferLen(len(arg997))
		defer mbTrans998.Close()
		_, err999 := mbTrans998.WriteString(arg997)
		if err999 != nil {
			Usage()
			return
		}
		factory1000 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1001 := factory1000.GetProtocol(mbTrans998)
		argvalue2 := services.NewFromInfo()
		err1002 := argvalue2.Read(jsProt1001)
		if err1002 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.GetFriendGroups(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getFriendOperationRecords":
		if flag.NArg()-1 != 8 {
			fmt.Fprintln(os.Stderr, "GetFriendOperationRecords requires 8 args")
			flag.Usage()
		}
		argvalue0, err1003 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1003 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1004 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1004 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err1005 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err1005 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err1006 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err1006 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		tmp4, err := (strconv.Atoi(flag.Arg(5)))
		if err != nil {
			Usage()
			return
		}
		argvalue4 := services.FriendOperationStatus(tmp4)
		value4 := argvalue4
		argvalue5 := flag.Arg(6) == "true"
		value5 := argvalue5
		tmp6, err1008 := (strconv.Atoi(flag.Arg(7)))
		if err1008 != nil {
			Usage()
			return
		}
		argvalue6 := int32(tmp6)
		value6 := argvalue6
		arg1009 := flag.Arg(8)
		mbTrans1010 := thrift.NewTMemoryBufferLen(len(arg1009))
		defer mbTrans1010.Close()
		_, err1011 := mbTrans1010.WriteString(arg1009)
		if err1011 != nil {
			Usage()
			return
		}
		factory1012 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1013 := factory1012.GetProtocol(mbTrans1010)
		argvalue7 := services.NewFromInfo()
		err1014 := argvalue7.Read(jsProt1013)
		if err1014 != nil {
			Usage()
			return
		}
		value7 := argvalue7
		fmt.Print(client.GetFriendOperationRecords(value0, value1, value2, value3, value4, value5, value6, value7))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
示例#12
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewResourceManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "createResource":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "CreateResource requires 3 args")
			flag.Usage()
		}
		arg664 := flag.Arg(1)
		mbTrans665 := thrift.NewTMemoryBufferLen(len(arg664))
		defer mbTrans665.Close()
		_, err666 := mbTrans665.WriteString(arg664)
		if err666 != nil {
			Usage()
			return
		}
		factory667 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt668 := factory667.GetProtocol(mbTrans665)
		argvalue0 := services.NewResource()
		err669 := argvalue0.Read(jsProt668)
		if err669 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg670 := flag.Arg(2)
		mbTrans671 := thrift.NewTMemoryBufferLen(len(arg670))
		defer mbTrans671.Close()
		_, err672 := mbTrans671.WriteString(arg670)
		if err672 != nil {
			Usage()
			return
		}
		factory673 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt674 := factory673.GetProtocol(mbTrans671)
		containerStruct1 := services.NewCreateResourceArgs()
		err675 := containerStruct1.ReadField2(jsProt674)
		if err675 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.Tags
		value1 := argvalue1
		arg676 := flag.Arg(3)
		mbTrans677 := thrift.NewTMemoryBufferLen(len(arg676))
		defer mbTrans677.Close()
		_, err678 := mbTrans677.WriteString(arg676)
		if err678 != nil {
			Usage()
			return
		}
		factory679 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt680 := factory679.GetProtocol(mbTrans677)
		argvalue2 := services.NewFromInfo()
		err681 := argvalue2.Read(jsProt680)
		if err681 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.CreateResource(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getResource":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "GetResource requires 3 args")
			flag.Usage()
		}
		argvalue0, err682 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err682 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err683 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err683 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg684 := flag.Arg(3)
		mbTrans685 := thrift.NewTMemoryBufferLen(len(arg684))
		defer mbTrans685.Close()
		_, err686 := mbTrans685.WriteString(arg684)
		if err686 != nil {
			Usage()
			return
		}
		factory687 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt688 := factory687.GetProtocol(mbTrans685)
		argvalue2 := services.NewFromInfo()
		err689 := argvalue2.Read(jsProt688)
		if err689 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.GetResource(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getResourceInfo":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "GetResourceInfo requires 3 args")
			flag.Usage()
		}
		argvalue0, err690 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err690 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err691 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err691 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg692 := flag.Arg(3)
		mbTrans693 := thrift.NewTMemoryBufferLen(len(arg692))
		defer mbTrans693.Close()
		_, err694 := mbTrans693.WriteString(arg692)
		if err694 != nil {
			Usage()
			return
		}
		factory695 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt696 := factory695.GetProtocol(mbTrans693)
		argvalue2 := services.NewFromInfo()
		err697 := argvalue2.Read(jsProt696)
		if err697 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.GetResourceInfo(value0, value1, value2))
		fmt.Print("\n")
		break
	case "updateResource":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "UpdateResource requires 5 args")
			flag.Usage()
		}
		arg698 := flag.Arg(1)
		mbTrans699 := thrift.NewTMemoryBufferLen(len(arg698))
		defer mbTrans699.Close()
		_, err700 := mbTrans699.WriteString(arg698)
		if err700 != nil {
			Usage()
			return
		}
		factory701 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt702 := factory701.GetProtocol(mbTrans699)
		argvalue0 := services.NewResource()
		err703 := argvalue0.Read(jsProt702)
		if err703 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err704 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err704 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err705 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err705 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		arg706 := flag.Arg(4)
		mbTrans707 := thrift.NewTMemoryBufferLen(len(arg706))
		defer mbTrans707.Close()
		_, err708 := mbTrans707.WriteString(arg706)
		if err708 != nil {
			Usage()
			return
		}
		factory709 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt710 := factory709.GetProtocol(mbTrans707)
		containerStruct3 := services.NewUpdateResourceArgs()
		err711 := containerStruct3.ReadField4(jsProt710)
		if err711 != nil {
			Usage()
			return
		}
		argvalue3 := containerStruct3.Tags
		value3 := argvalue3
		arg712 := flag.Arg(5)
		mbTrans713 := thrift.NewTMemoryBufferLen(len(arg712))
		defer mbTrans713.Close()
		_, err714 := mbTrans713.WriteString(arg712)
		if err714 != nil {
			Usage()
			return
		}
		factory715 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt716 := factory715.GetProtocol(mbTrans713)
		argvalue4 := services.NewFromInfo()
		err717 := argvalue4.Read(jsProt716)
		if err717 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.UpdateResource(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "deleteResourceBySharedId":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "DeleteResourceBySharedId requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1, err719 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err719 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg720 := flag.Arg(3)
		mbTrans721 := thrift.NewTMemoryBufferLen(len(arg720))
		defer mbTrans721.Close()
		_, err722 := mbTrans721.WriteString(arg720)
		if err722 != nil {
			Usage()
			return
		}
		factory723 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt724 := factory723.GetProtocol(mbTrans721)
		argvalue2 := services.NewFromInfo()
		err725 := argvalue2.Read(jsProt724)
		if err725 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.DeleteResourceBySharedId(value0, value1, value2))
		fmt.Print("\n")
		break
	case "deleteResource":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "DeleteResource requires 3 args")
			flag.Usage()
		}
		argvalue0, err726 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err726 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err727 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err727 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg728 := flag.Arg(3)
		mbTrans729 := thrift.NewTMemoryBufferLen(len(arg728))
		defer mbTrans729.Close()
		_, err730 := mbTrans729.WriteString(arg728)
		if err730 != nil {
			Usage()
			return
		}
		factory731 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt732 := factory731.GetProtocol(mbTrans729)
		argvalue2 := services.NewFromInfo()
		err733 := argvalue2.Read(jsProt732)
		if err733 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.DeleteResource(value0, value1, value2))
		fmt.Print("\n")
		break
	case "shareResource":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "ShareResource requires 5 args")
			flag.Usage()
		}
		arg734 := flag.Arg(1)
		mbTrans735 := thrift.NewTMemoryBufferLen(len(arg734))
		defer mbTrans735.Close()
		_, err736 := mbTrans735.WriteString(arg734)
		if err736 != nil {
			Usage()
			return
		}
		factory737 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt738 := factory737.GetProtocol(mbTrans735)
		argvalue0 := services.NewResource()
		err739 := argvalue0.Read(jsProt738)
		if err739 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg740 := flag.Arg(2)
		mbTrans741 := thrift.NewTMemoryBufferLen(len(arg740))
		defer mbTrans741.Close()
		_, err742 := mbTrans741.WriteString(arg740)
		if err742 != nil {
			Usage()
			return
		}
		factory743 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt744 := factory743.GetProtocol(mbTrans741)
		containerStruct1 := services.NewShareResourceArgs()
		err745 := containerStruct1.ReadField2(jsProt744)
		if err745 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.ShareGroups
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.Zone(tmp2)
		value2 := argvalue2
		argvalue3, err746 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err746 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		arg747 := flag.Arg(5)
		mbTrans748 := thrift.NewTMemoryBufferLen(len(arg747))
		defer mbTrans748.Close()
		_, err749 := mbTrans748.WriteString(arg747)
		if err749 != nil {
			Usage()
			return
		}
		factory750 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt751 := factory750.GetProtocol(mbTrans748)
		argvalue4 := services.NewFromInfo()
		err752 := argvalue4.Read(jsProt751)
		if err752 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.ShareResource(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "getSharedResources":
		if flag.NArg()-1 != 9 {
			fmt.Fprintln(os.Stderr, "GetSharedResources requires 9 args")
			flag.Usage()
		}
		argvalue0, err753 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err753 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.Zone(tmp1)
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceType(tmp2)
		value2 := argvalue2
		argvalue3, err754 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err754 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err755 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err755 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5, err756 := (strconv.ParseInt(flag.Arg(6), 10, 64))
		if err756 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		argvalue6 := flag.Arg(7) == "true"
		value6 := argvalue6
		tmp7, err758 := (strconv.Atoi(flag.Arg(8)))
		if err758 != nil {
			Usage()
			return
		}
		argvalue7 := int32(tmp7)
		value7 := argvalue7
		arg759 := flag.Arg(9)
		mbTrans760 := thrift.NewTMemoryBufferLen(len(arg759))
		defer mbTrans760.Close()
		_, err761 := mbTrans760.WriteString(arg759)
		if err761 != nil {
			Usage()
			return
		}
		factory762 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt763 := factory762.GetProtocol(mbTrans760)
		argvalue8 := services.NewFromInfo()
		err764 := argvalue8.Read(jsProt763)
		if err764 != nil {
			Usage()
			return
		}
		value8 := argvalue8
		fmt.Print(client.GetSharedResources(value0, value1, value2, value3, value4, value5, value6, value7, value8))
		fmt.Print("\n")
		break
	case "cancelSharedResource":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "CancelSharedResource requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg766 := flag.Arg(2)
		mbTrans767 := thrift.NewTMemoryBufferLen(len(arg766))
		defer mbTrans767.Close()
		_, err768 := mbTrans767.WriteString(arg766)
		if err768 != nil {
			Usage()
			return
		}
		factory769 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt770 := factory769.GetProtocol(mbTrans767)
		argvalue1 := services.NewFromInfo()
		err771 := argvalue1.Read(jsProt770)
		if err771 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.CancelSharedResource(value0, value1))
		fmt.Print("\n")
		break
	case "getUserResources":
		if flag.NArg()-1 != 8 {
			fmt.Fprintln(os.Stderr, "GetUserResources requires 8 args")
			flag.Usage()
		}
		argvalue0, err772 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err772 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.ResourceType(tmp1)
		value1 := argvalue1
		argvalue2, err773 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err773 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err774 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err774 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err775 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err775 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5 := flag.Arg(6) == "true"
		value5 := argvalue5
		tmp6, err777 := (strconv.Atoi(flag.Arg(7)))
		if err777 != nil {
			Usage()
			return
		}
		argvalue6 := int32(tmp6)
		value6 := argvalue6
		arg778 := flag.Arg(8)
		mbTrans779 := thrift.NewTMemoryBufferLen(len(arg778))
		defer mbTrans779.Close()
		_, err780 := mbTrans779.WriteString(arg778)
		if err780 != nil {
			Usage()
			return
		}
		factory781 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt782 := factory781.GetProtocol(mbTrans779)
		argvalue7 := services.NewFromInfo()
		err783 := argvalue7.Read(jsProt782)
		if err783 != nil {
			Usage()
			return
		}
		value7 := argvalue7
		fmt.Print(client.GetUserResources(value0, value1, value2, value3, value4, value5, value6, value7))
		fmt.Print("\n")
		break
	case "addComment":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "AddComment requires 2 args")
			flag.Usage()
		}
		arg784 := flag.Arg(1)
		mbTrans785 := thrift.NewTMemoryBufferLen(len(arg784))
		defer mbTrans785.Close()
		_, err786 := mbTrans785.WriteString(arg784)
		if err786 != nil {
			Usage()
			return
		}
		factory787 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt788 := factory787.GetProtocol(mbTrans785)
		argvalue0 := services.NewComment()
		err789 := argvalue0.Read(jsProt788)
		if err789 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg790 := flag.Arg(2)
		mbTrans791 := thrift.NewTMemoryBufferLen(len(arg790))
		defer mbTrans791.Close()
		_, err792 := mbTrans791.WriteString(arg790)
		if err792 != nil {
			Usage()
			return
		}
		factory793 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt794 := factory793.GetProtocol(mbTrans791)
		argvalue1 := services.NewFromInfo()
		err795 := argvalue1.Read(jsProt794)
		if err795 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.AddComment(value0, value1))
		fmt.Print("\n")
		break
	case "deleteComment":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "DeleteComment requires 6 args")
			flag.Usage()
		}
		argvalue0, err796 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err796 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err797 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err797 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err798 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err798 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err799 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err799 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err800 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err800 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		arg801 := flag.Arg(6)
		mbTrans802 := thrift.NewTMemoryBufferLen(len(arg801))
		defer mbTrans802.Close()
		_, err803 := mbTrans802.WriteString(arg801)
		if err803 != nil {
			Usage()
			return
		}
		factory804 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt805 := factory804.GetProtocol(mbTrans802)
		argvalue5 := services.NewFromInfo()
		err806 := argvalue5.Read(jsProt805)
		if err806 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.DeleteComment(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "getComments":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "GetComments requires 7 args")
			flag.Usage()
		}
		argvalue0, err807 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err807 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err808 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err808 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err809 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err809 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err810 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err810 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4 := flag.Arg(5) == "true"
		value4 := argvalue4
		tmp5, err812 := (strconv.Atoi(flag.Arg(6)))
		if err812 != nil {
			Usage()
			return
		}
		argvalue5 := int32(tmp5)
		value5 := argvalue5
		arg813 := flag.Arg(7)
		mbTrans814 := thrift.NewTMemoryBufferLen(len(arg813))
		defer mbTrans814.Close()
		_, err815 := mbTrans814.WriteString(arg813)
		if err815 != nil {
			Usage()
			return
		}
		factory816 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt817 := factory816.GetProtocol(mbTrans814)
		argvalue6 := services.NewFromInfo()
		err818 := argvalue6.Read(jsProt817)
		if err818 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.GetComments(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "operateThumb":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "OperateThumb requires 6 args")
			flag.Usage()
		}
		argvalue0, err819 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err819 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err820 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err820 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ThumbType(tmp2)
		value2 := argvalue2
		argvalue3, err821 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err821 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		tmp4, err := (strconv.Atoi(flag.Arg(5)))
		if err != nil {
			Usage()
			return
		}
		argvalue4 := services.ResourceType(tmp4)
		value4 := argvalue4
		arg822 := flag.Arg(6)
		mbTrans823 := thrift.NewTMemoryBufferLen(len(arg822))
		defer mbTrans823.Close()
		_, err824 := mbTrans823.WriteString(arg822)
		if err824 != nil {
			Usage()
			return
		}
		factory825 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt826 := factory825.GetProtocol(mbTrans823)
		argvalue5 := services.NewFromInfo()
		err827 := argvalue5.Read(jsProt826)
		if err827 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.OperateThumb(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "getThumbs":
		if flag.NArg()-1 != 8 {
			fmt.Fprintln(os.Stderr, "GetThumbs requires 8 args")
			flag.Usage()
		}
		argvalue0, err828 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err828 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err829 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err829 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ThumbType(tmp2)
		value2 := argvalue2
		argvalue3, err830 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err830 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err831 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err831 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5 := flag.Arg(6) == "true"
		value5 := argvalue5
		tmp6, err833 := (strconv.Atoi(flag.Arg(7)))
		if err833 != nil {
			Usage()
			return
		}
		argvalue6 := int32(tmp6)
		value6 := argvalue6
		arg834 := flag.Arg(8)
		mbTrans835 := thrift.NewTMemoryBufferLen(len(arg834))
		defer mbTrans835.Close()
		_, err836 := mbTrans835.WriteString(arg834)
		if err836 != nil {
			Usage()
			return
		}
		factory837 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt838 := factory837.GetProtocol(mbTrans835)
		argvalue7 := services.NewFromInfo()
		err839 := argvalue7.Read(jsProt838)
		if err839 != nil {
			Usage()
			return
		}
		value7 := argvalue7
		fmt.Print(client.GetThumbs(value0, value1, value2, value3, value4, value5, value6, value7))
		fmt.Print("\n")
		break
	case "registerResourceNotification":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "RegisterResourceNotification requires 3 args")
			flag.Usage()
		}
		argvalue0, err840 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err840 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err841 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err841 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg842 := flag.Arg(3)
		mbTrans843 := thrift.NewTMemoryBufferLen(len(arg842))
		defer mbTrans843.Close()
		_, err844 := mbTrans843.WriteString(arg842)
		if err844 != nil {
			Usage()
			return
		}
		factory845 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt846 := factory845.GetProtocol(mbTrans843)
		argvalue2 := services.NewFromInfo()
		err847 := argvalue2.Read(jsProt846)
		if err847 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.RegisterResourceNotification(value0, value1, value2))
		fmt.Print("\n")
		break
	case "unregisterResourceNotification":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "UnregisterResourceNotification requires 4 args")
			flag.Usage()
		}
		argvalue0, err848 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err848 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err849 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err849 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceType(tmp2)
		value2 := argvalue2
		arg850 := flag.Arg(4)
		mbTrans851 := thrift.NewTMemoryBufferLen(len(arg850))
		defer mbTrans851.Close()
		_, err852 := mbTrans851.WriteString(arg850)
		if err852 != nil {
			Usage()
			return
		}
		factory853 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt854 := factory853.GetProtocol(mbTrans851)
		argvalue3 := services.NewFromInfo()
		err855 := argvalue3.Read(jsProt854)
		if err855 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.UnregisterResourceNotification(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "sendResourceNotification":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "SendResourceNotification requires 5 args")
			flag.Usage()
		}
		argvalue0, err856 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err856 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err857 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err857 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg858 := flag.Arg(3)
		mbTrans859 := thrift.NewTMemoryBufferLen(len(arg858))
		defer mbTrans859.Close()
		_, err860 := mbTrans859.WriteString(arg858)
		if err860 != nil {
			Usage()
			return
		}
		factory861 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt862 := factory861.GetProtocol(mbTrans859)
		argvalue2 := services.NewComment()
		err863 := argvalue2.Read(jsProt862)
		if err863 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err864 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err864 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		arg865 := flag.Arg(5)
		mbTrans866 := thrift.NewTMemoryBufferLen(len(arg865))
		defer mbTrans866.Close()
		_, err867 := mbTrans866.WriteString(arg865)
		if err867 != nil {
			Usage()
			return
		}
		factory868 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt869 := factory868.GetProtocol(mbTrans866)
		argvalue4 := services.NewFromInfo()
		err870 := argvalue4.Read(jsProt869)
		if err870 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.SendResourceNotification(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "getCommentsHistory":
		if flag.NArg()-1 != 8 {
			fmt.Fprintln(os.Stderr, "GetCommentsHistory requires 8 args")
			flag.Usage()
		}
		argvalue0, err871 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err871 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.CommentHistoryType(tmp1)
		value1 := argvalue1
		argvalue2, err872 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err872 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err873 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err873 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err874 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err874 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5 := flag.Arg(6) == "true"
		value5 := argvalue5
		tmp6, err876 := (strconv.Atoi(flag.Arg(7)))
		if err876 != nil {
			Usage()
			return
		}
		argvalue6 := int32(tmp6)
		value6 := argvalue6
		arg877 := flag.Arg(8)
		mbTrans878 := thrift.NewTMemoryBufferLen(len(arg877))
		defer mbTrans878.Close()
		_, err879 := mbTrans878.WriteString(arg877)
		if err879 != nil {
			Usage()
			return
		}
		factory880 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt881 := factory880.GetProtocol(mbTrans878)
		argvalue7 := services.NewFromInfo()
		err882 := argvalue7.Read(jsProt881)
		if err882 != nil {
			Usage()
			return
		}
		value7 := argvalue7
		fmt.Print(client.GetCommentsHistory(value0, value1, value2, value3, value4, value5, value6, value7))
		fmt.Print("\n")
		break
	case "deleteCommentHistory":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "DeleteCommentHistory requires 6 args")
			flag.Usage()
		}
		argvalue0, err883 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err883 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.CommentHistoryType(tmp1)
		value1 := argvalue1
		argvalue2, err884 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err884 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err885 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err885 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err886 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err886 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		arg887 := flag.Arg(6)
		mbTrans888 := thrift.NewTMemoryBufferLen(len(arg887))
		defer mbTrans888.Close()
		_, err889 := mbTrans888.WriteString(arg887)
		if err889 != nil {
			Usage()
			return
		}
		factory890 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt891 := factory890.GetProtocol(mbTrans888)
		argvalue5 := services.NewFromInfo()
		err892 := argvalue5.Read(jsProt891)
		if err892 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.DeleteCommentHistory(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "updateGroupResourceName":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "UpdateGroupResourceName requires 7 args")
			flag.Usage()
		}
		argvalue0, err893 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err893 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.Zone(tmp1)
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceType(tmp2)
		value2 := argvalue2
		argvalue3, err894 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err894 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err895 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err895 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5 := flag.Arg(6)
		value5 := argvalue5
		arg897 := flag.Arg(7)
		mbTrans898 := thrift.NewTMemoryBufferLen(len(arg897))
		defer mbTrans898.Close()
		_, err899 := mbTrans898.WriteString(arg897)
		if err899 != nil {
			Usage()
			return
		}
		factory900 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt901 := factory900.GetProtocol(mbTrans898)
		argvalue6 := services.NewFromInfo()
		err902 := argvalue6.Read(jsProt901)
		if err902 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.UpdateGroupResourceName(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "getSharedGroupResource":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetSharedGroupResource requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg904 := flag.Arg(2)
		mbTrans905 := thrift.NewTMemoryBufferLen(len(arg904))
		defer mbTrans905.Close()
		_, err906 := mbTrans905.WriteString(arg904)
		if err906 != nil {
			Usage()
			return
		}
		factory907 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt908 := factory907.GetProtocol(mbTrans905)
		argvalue1 := services.NewFromInfo()
		err909 := argvalue1.Read(jsProt908)
		if err909 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetSharedGroupResource(value0, value1))
		fmt.Print("\n")
		break
	case "getResourceChatRoomViewer":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "GetResourceChatRoomViewer requires 4 args")
			flag.Usage()
		}
		argvalue0, err910 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err910 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err911 := (strconv.Atoi(flag.Arg(2)))
		if err911 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		argvalue2, err912 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err912 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		arg913 := flag.Arg(4)
		mbTrans914 := thrift.NewTMemoryBufferLen(len(arg913))
		defer mbTrans914.Close()
		_, err915 := mbTrans914.WriteString(arg913)
		if err915 != nil {
			Usage()
			return
		}
		factory916 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt917 := factory916.GetProtocol(mbTrans914)
		argvalue3 := services.NewFromInfo()
		err918 := argvalue3.Read(jsProt917)
		if err918 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.GetResourceChatRoomViewer(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getResourceChatRoomViewerCount":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetResourceChatRoomViewerCount requires 2 args")
			flag.Usage()
		}
		argvalue0, err919 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err919 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg920 := flag.Arg(2)
		mbTrans921 := thrift.NewTMemoryBufferLen(len(arg920))
		defer mbTrans921.Close()
		_, err922 := mbTrans921.WriteString(arg920)
		if err922 != nil {
			Usage()
			return
		}
		factory923 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt924 := factory923.GetProtocol(mbTrans921)
		argvalue1 := services.NewFromInfo()
		err925 := argvalue1.Read(jsProt924)
		if err925 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetResourceChatRoomViewerCount(value0, value1))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
示例#13
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewAccessManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "grantUserAccessToGroupRegion":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GrantUserAccessToGroupRegion requires 6 args")
			flag.Usage()
		}
		argvalue0, err455 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err455 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err456 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err456 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg457 := flag.Arg(3)
		mbTrans458 := thrift.NewTMemoryBufferLen(len(arg457))
		defer mbTrans458.Close()
		_, err459 := mbTrans458.WriteString(arg457)
		if err459 != nil {
			Usage()
			return
		}
		factory460 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt461 := factory460.GetProtocol(mbTrans458)
		containerStruct2 := services.NewGrantUserAccessToGroupRegionArgs()
		err462 := containerStruct2.ReadField3(jsProt461)
		if err462 != nil {
			Usage()
			return
		}
		argvalue2 := containerStruct2.Zones
		value2 := argvalue2
		tmp3, err463 := (strconv.Atoi(flag.Arg(4)))
		if err463 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		tmp4, err464 := (strconv.Atoi(flag.Arg(5)))
		if err464 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		arg465 := flag.Arg(6)
		mbTrans466 := thrift.NewTMemoryBufferLen(len(arg465))
		defer mbTrans466.Close()
		_, err467 := mbTrans466.WriteString(arg465)
		if err467 != nil {
			Usage()
			return
		}
		factory468 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt469 := factory468.GetProtocol(mbTrans466)
		argvalue5 := services.NewFromInfo()
		err470 := argvalue5.Read(jsProt469)
		if err470 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.GrantUserAccessToGroupRegion(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "hasAccessToRegion":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "HasAccessToRegion requires 4 args")
			flag.Usage()
		}
		argvalue0, err471 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err471 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err472 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err472 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.Zone(tmp2)
		value2 := argvalue2
		arg473 := flag.Arg(4)
		mbTrans474 := thrift.NewTMemoryBufferLen(len(arg473))
		defer mbTrans474.Close()
		_, err475 := mbTrans474.WriteString(arg473)
		if err475 != nil {
			Usage()
			return
		}
		factory476 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt477 := factory476.GetProtocol(mbTrans474)
		argvalue3 := services.NewFromInfo()
		err478 := argvalue3.Read(jsProt477)
		if err478 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.HasAccessToRegion(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getAccessableGroupResources":
		if flag.NArg()-1 != 10 {
			fmt.Fprintln(os.Stderr, "GetAccessableGroupResources requires 10 args")
			flag.Usage()
		}
		argvalue0, err479 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err479 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err480 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err480 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.Zone(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.ResourceType(tmp3)
		value3 := argvalue3
		argvalue4, err481 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err481 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5, err482 := (strconv.ParseInt(flag.Arg(6), 10, 64))
		if err482 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		argvalue6, err483 := (strconv.ParseInt(flag.Arg(7), 10, 64))
		if err483 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		argvalue7 := flag.Arg(8) == "true"
		value7 := argvalue7
		tmp8, err485 := (strconv.Atoi(flag.Arg(9)))
		if err485 != nil {
			Usage()
			return
		}
		argvalue8 := int32(tmp8)
		value8 := argvalue8
		arg486 := flag.Arg(10)
		mbTrans487 := thrift.NewTMemoryBufferLen(len(arg486))
		defer mbTrans487.Close()
		_, err488 := mbTrans487.WriteString(arg486)
		if err488 != nil {
			Usage()
			return
		}
		factory489 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt490 := factory489.GetProtocol(mbTrans487)
		argvalue9 := services.NewFromInfo()
		err491 := argvalue9.Read(jsProt490)
		if err491 != nil {
			Usage()
			return
		}
		value9 := argvalue9
		fmt.Print(client.GetAccessableGroupResources(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewResourceCategoryManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "getChildren":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GetChildren requires 6 args")
			flag.Usage()
		}
		argvalue0, err1063 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1063 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1064 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1064 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceNodeType(tmp2)
		value2 := argvalue2
		argvalue3, err1065 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err1065 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		tmp4, err1066 := (strconv.Atoi(flag.Arg(5)))
		if err1066 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		arg1067 := flag.Arg(6)
		mbTrans1068 := thrift.NewTMemoryBufferLen(len(arg1067))
		defer mbTrans1068.Close()
		_, err1069 := mbTrans1068.WriteString(arg1067)
		if err1069 != nil {
			Usage()
			return
		}
		factory1070 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1071 := factory1070.GetProtocol(mbTrans1068)
		argvalue5 := services.NewFromInfo()
		err1072 := argvalue5.Read(jsProt1071)
		if err1072 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.GetChildren(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "getChildrenByType":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GetChildrenByType requires 6 args")
			flag.Usage()
		}
		argvalue0, err1073 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1073 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1074 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1074 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceNodeType(tmp2)
		value2 := argvalue2
		argvalue3, err1075 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err1075 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		tmp4, err1076 := (strconv.Atoi(flag.Arg(5)))
		if err1076 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		arg1077 := flag.Arg(6)
		mbTrans1078 := thrift.NewTMemoryBufferLen(len(arg1077))
		defer mbTrans1078.Close()
		_, err1079 := mbTrans1078.WriteString(arg1077)
		if err1079 != nil {
			Usage()
			return
		}
		factory1080 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1081 := factory1080.GetProtocol(mbTrans1078)
		argvalue5 := services.NewFromInfo()
		err1082 := argvalue5.Read(jsProt1081)
		if err1082 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.GetChildrenByType(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "removeChild":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "RemoveChild requires 5 args")
			flag.Usage()
		}
		argvalue0, err1083 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1083 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1084 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1084 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceNodeType(tmp2)
		value2 := argvalue2
		argvalue3, err1085 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err1085 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		arg1086 := flag.Arg(5)
		mbTrans1087 := thrift.NewTMemoryBufferLen(len(arg1086))
		defer mbTrans1087.Close()
		_, err1088 := mbTrans1087.WriteString(arg1086)
		if err1088 != nil {
			Usage()
			return
		}
		factory1089 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1090 := factory1089.GetProtocol(mbTrans1087)
		argvalue4 := services.NewFromInfo()
		err1091 := argvalue4.Read(jsProt1090)
		if err1091 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.RemoveChild(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "moveChild":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "MoveChild requires 7 args")
			flag.Usage()
		}
		argvalue0, err1092 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1092 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1093 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1093 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceNodeType(tmp2)
		value2 := argvalue2
		argvalue3, err1094 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err1094 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err1095 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err1095 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5 := flag.Arg(6) == "true"
		value5 := argvalue5
		arg1097 := flag.Arg(7)
		mbTrans1098 := thrift.NewTMemoryBufferLen(len(arg1097))
		defer mbTrans1098.Close()
		_, err1099 := mbTrans1098.WriteString(arg1097)
		if err1099 != nil {
			Usage()
			return
		}
		factory1100 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1101 := factory1100.GetProtocol(mbTrans1098)
		argvalue6 := services.NewFromInfo()
		err1102 := argvalue6.Read(jsProt1101)
		if err1102 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.MoveChild(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "renameChild":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "RenameChild requires 6 args")
			flag.Usage()
		}
		argvalue0, err1103 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1103 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1104 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1104 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceNodeType(tmp2)
		value2 := argvalue2
		argvalue3, err1105 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err1105 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4 := flag.Arg(5)
		value4 := argvalue4
		arg1107 := flag.Arg(6)
		mbTrans1108 := thrift.NewTMemoryBufferLen(len(arg1107))
		defer mbTrans1108.Close()
		_, err1109 := mbTrans1108.WriteString(arg1107)
		if err1109 != nil {
			Usage()
			return
		}
		factory1110 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1111 := factory1110.GetProtocol(mbTrans1108)
		argvalue5 := services.NewFromInfo()
		err1112 := argvalue5.Read(jsProt1111)
		if err1112 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.RenameChild(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "createCategory":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "CreateCategory requires 4 args")
			flag.Usage()
		}
		argvalue0, err1113 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1113 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1114 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1114 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		arg1116 := flag.Arg(4)
		mbTrans1117 := thrift.NewTMemoryBufferLen(len(arg1116))
		defer mbTrans1117.Close()
		_, err1118 := mbTrans1117.WriteString(arg1116)
		if err1118 != nil {
			Usage()
			return
		}
		factory1119 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1120 := factory1119.GetProtocol(mbTrans1117)
		argvalue3 := services.NewFromInfo()
		err1121 := argvalue3.Read(jsProt1120)
		if err1121 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.CreateCategory(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "assignCategory":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "AssignCategory requires 6 args")
			flag.Usage()
		}
		argvalue0, err1122 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1122 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1123 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1123 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg1124 := flag.Arg(3)
		mbTrans1125 := thrift.NewTMemoryBufferLen(len(arg1124))
		defer mbTrans1125.Close()
		_, err1126 := mbTrans1125.WriteString(arg1124)
		if err1126 != nil {
			Usage()
			return
		}
		factory1127 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1128 := factory1127.GetProtocol(mbTrans1125)
		argvalue2 := services.NewResource()
		err1129 := argvalue2.Read(jsProt1128)
		if err1129 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.Zone(tmp3)
		value3 := argvalue3
		argvalue4 := flag.Arg(5)
		value4 := argvalue4
		arg1131 := flag.Arg(6)
		mbTrans1132 := thrift.NewTMemoryBufferLen(len(arg1131))
		defer mbTrans1132.Close()
		_, err1133 := mbTrans1132.WriteString(arg1131)
		if err1133 != nil {
			Usage()
			return
		}
		factory1134 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1135 := factory1134.GetProtocol(mbTrans1132)
		argvalue5 := services.NewFromInfo()
		err1136 := argvalue5.Read(jsProt1135)
		if err1136 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.AssignCategory(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "assignResourceZone":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "AssignResourceZone requires 7 args")
			flag.Usage()
		}
		argvalue0, err1137 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1137 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1138 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1138 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceNodeType(tmp2)
		value2 := argvalue2
		argvalue3, err1139 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err1139 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		tmp4, err := (strconv.Atoi(flag.Arg(5)))
		if err != nil {
			Usage()
			return
		}
		argvalue4 := services.Zone(tmp4)
		value4 := argvalue4
		argvalue5 := flag.Arg(6)
		value5 := argvalue5
		arg1141 := flag.Arg(7)
		mbTrans1142 := thrift.NewTMemoryBufferLen(len(arg1141))
		defer mbTrans1142.Close()
		_, err1143 := mbTrans1142.WriteString(arg1141)
		if err1143 != nil {
			Usage()
			return
		}
		factory1144 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1145 := factory1144.GetProtocol(mbTrans1142)
		argvalue6 := services.NewFromInfo()
		err1146 := argvalue6.Read(jsProt1145)
		if err1146 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.AssignResourceZone(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "assignUnclassifiedResourceZone":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "AssignUnclassifiedResourceZone requires 4 args")
			flag.Usage()
		}
		tmp0, err := (strconv.Atoi(flag.Arg(1)))
		if err != nil {
			Usage()
			return
		}
		argvalue0 := services.Zone(tmp0)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		argvalue2, err1148 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err1148 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		arg1149 := flag.Arg(4)
		mbTrans1150 := thrift.NewTMemoryBufferLen(len(arg1149))
		defer mbTrans1150.Close()
		_, err1151 := mbTrans1150.WriteString(arg1149)
		if err1151 != nil {
			Usage()
			return
		}
		factory1152 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1153 := factory1152.GetProtocol(mbTrans1150)
		argvalue3 := services.NewFromInfo()
		err1154 := argvalue3.Read(jsProt1153)
		if err1154 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.AssignUnclassifiedResourceZone(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getUnclassifiedGroupResources":
		if flag.NArg()-1 != 9 {
			fmt.Fprintln(os.Stderr, "GetUnclassifiedGroupResources requires 9 args")
			flag.Usage()
		}
		argvalue0, err1155 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1155 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.Zone(tmp1)
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceType(tmp2)
		value2 := argvalue2
		argvalue3, err1156 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err1156 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err1157 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err1157 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5, err1158 := (strconv.ParseInt(flag.Arg(6), 10, 64))
		if err1158 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		argvalue6 := flag.Arg(7) == "true"
		value6 := argvalue6
		tmp7, err1160 := (strconv.Atoi(flag.Arg(8)))
		if err1160 != nil {
			Usage()
			return
		}
		argvalue7 := int32(tmp7)
		value7 := argvalue7
		arg1161 := flag.Arg(9)
		mbTrans1162 := thrift.NewTMemoryBufferLen(len(arg1161))
		defer mbTrans1162.Close()
		_, err1163 := mbTrans1162.WriteString(arg1161)
		if err1163 != nil {
			Usage()
			return
		}
		factory1164 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1165 := factory1164.GetProtocol(mbTrans1162)
		argvalue8 := services.NewFromInfo()
		err1166 := argvalue8.Read(jsProt1165)
		if err1166 != nil {
			Usage()
			return
		}
		value8 := argvalue8
		fmt.Print(client.GetUnclassifiedGroupResources(value0, value1, value2, value3, value4, value5, value6, value7, value8))
		fmt.Print("\n")
		break
	case "getUnclassifiedGroupResourcesByType":
		if flag.NArg()-1 != 9 {
			fmt.Fprintln(os.Stderr, "GetUnclassifiedGroupResourcesByType requires 9 args")
			flag.Usage()
		}
		argvalue0, err1167 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1167 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.Zone(tmp1)
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceType(tmp2)
		value2 := argvalue2
		argvalue3, err1168 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err1168 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err1169 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err1169 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5, err1170 := (strconv.ParseInt(flag.Arg(6), 10, 64))
		if err1170 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		argvalue6 := flag.Arg(7) == "true"
		value6 := argvalue6
		tmp7, err1172 := (strconv.Atoi(flag.Arg(8)))
		if err1172 != nil {
			Usage()
			return
		}
		argvalue7 := int32(tmp7)
		value7 := argvalue7
		arg1173 := flag.Arg(9)
		mbTrans1174 := thrift.NewTMemoryBufferLen(len(arg1173))
		defer mbTrans1174.Close()
		_, err1175 := mbTrans1174.WriteString(arg1173)
		if err1175 != nil {
			Usage()
			return
		}
		factory1176 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1177 := factory1176.GetProtocol(mbTrans1174)
		argvalue8 := services.NewFromInfo()
		err1178 := argvalue8.Read(jsProt1177)
		if err1178 != nil {
			Usage()
			return
		}
		value8 := argvalue8
		fmt.Print(client.GetUnclassifiedGroupResourcesByType(value0, value1, value2, value3, value4, value5, value6, value7, value8))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewResourceHistoryManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "getResourceViewHistory":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "GetResourceViewHistory requires 7 args")
			flag.Usage()
		}
		argvalue0, err1550 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1550 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1551 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1551 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err1552 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err1552 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err1553 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err1553 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4 := flag.Arg(5) == "true"
		value4 := argvalue4
		tmp5, err1555 := (strconv.Atoi(flag.Arg(6)))
		if err1555 != nil {
			Usage()
			return
		}
		argvalue5 := int32(tmp5)
		value5 := argvalue5
		arg1556 := flag.Arg(7)
		mbTrans1557 := thrift.NewTMemoryBufferLen(len(arg1556))
		defer mbTrans1557.Close()
		_, err1558 := mbTrans1557.WriteString(arg1556)
		if err1558 != nil {
			Usage()
			return
		}
		factory1559 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1560 := factory1559.GetProtocol(mbTrans1557)
		argvalue6 := services.NewFromInfo()
		err1561 := argvalue6.Read(jsProt1560)
		if err1561 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.GetResourceViewHistory(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "deleteResourceViewHistory":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "DeleteResourceViewHistory requires 4 args")
			flag.Usage()
		}
		argvalue0, err1562 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1562 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1563 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1563 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err1564 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err1564 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		arg1565 := flag.Arg(4)
		mbTrans1566 := thrift.NewTMemoryBufferLen(len(arg1565))
		defer mbTrans1566.Close()
		_, err1567 := mbTrans1566.WriteString(arg1565)
		if err1567 != nil {
			Usage()
			return
		}
		factory1568 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1569 := factory1568.GetProtocol(mbTrans1566)
		argvalue3 := services.NewFromInfo()
		err1570 := argvalue3.Read(jsProt1569)
		if err1570 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.DeleteResourceViewHistory(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
示例#16
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewLiveManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "joinLive":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "JoinLive requires 3 args")
			flag.Usage()
		}
		argvalue0, err1189 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1189 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1190 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1190 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg1191 := flag.Arg(3)
		mbTrans1192 := thrift.NewTMemoryBufferLen(len(arg1191))
		defer mbTrans1192.Close()
		_, err1193 := mbTrans1192.WriteString(arg1191)
		if err1193 != nil {
			Usage()
			return
		}
		factory1194 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1195 := factory1194.GetProtocol(mbTrans1192)
		argvalue2 := services.NewFromInfo()
		err1196 := argvalue2.Read(jsProt1195)
		if err1196 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.JoinLive(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getLiveInfo":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "GetLiveInfo requires 3 args")
			flag.Usage()
		}
		argvalue0, err1197 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1197 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1198 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1198 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg1199 := flag.Arg(3)
		mbTrans1200 := thrift.NewTMemoryBufferLen(len(arg1199))
		defer mbTrans1200.Close()
		_, err1201 := mbTrans1200.WriteString(arg1199)
		if err1201 != nil {
			Usage()
			return
		}
		factory1202 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1203 := factory1202.GetProtocol(mbTrans1200)
		argvalue2 := services.NewFromInfo()
		err1204 := argvalue2.Read(jsProt1203)
		if err1204 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.GetLiveInfo(value0, value1, value2))
		fmt.Print("\n")
		break
	case "leaveLive":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "LeaveLive requires 3 args")
			flag.Usage()
		}
		argvalue0, err1205 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1205 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1206 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1206 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg1207 := flag.Arg(3)
		mbTrans1208 := thrift.NewTMemoryBufferLen(len(arg1207))
		defer mbTrans1208.Close()
		_, err1209 := mbTrans1208.WriteString(arg1207)
		if err1209 != nil {
			Usage()
			return
		}
		factory1210 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1211 := factory1210.GetProtocol(mbTrans1208)
		argvalue2 := services.NewFromInfo()
		err1212 := argvalue2.Read(jsProt1211)
		if err1212 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.LeaveLive(value0, value1, value2))
		fmt.Print("\n")
		break
	case "sendLiveMessage":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "SendLiveMessage requires 4 args")
			flag.Usage()
		}
		argvalue0, err1213 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1213 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err1214 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1214 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg1215 := flag.Arg(3)
		mbTrans1216 := thrift.NewTMemoryBufferLen(len(arg1215))
		defer mbTrans1216.Close()
		_, err1217 := mbTrans1216.WriteString(arg1215)
		if err1217 != nil {
			Usage()
			return
		}
		factory1218 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1219 := factory1218.GetProtocol(mbTrans1216)
		argvalue2 := services.NewComment()
		err1220 := argvalue2.Read(jsProt1219)
		if err1220 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		arg1221 := flag.Arg(4)
		mbTrans1222 := thrift.NewTMemoryBufferLen(len(arg1221))
		defer mbTrans1222.Close()
		_, err1223 := mbTrans1222.WriteString(arg1221)
		if err1223 != nil {
			Usage()
			return
		}
		factory1224 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1225 := factory1224.GetProtocol(mbTrans1222)
		argvalue3 := services.NewFromInfo()
		err1226 := argvalue3.Read(jsProt1225)
		if err1226 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.SendLiveMessage(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}