示例#1
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		fmt.Println("Invalid E-Mail or Password\n")
		flag.Usage()
		os.Exit(-1)
	}

	if flag.NArg()%2 == 0 {
		flag.Usage()
		os.Exit(-1)
	}
	imsi := flag.Arg(0)
	tags := make([]map[string]string, (flag.NArg()-1)/2)
	idx := 0
	for i := 1; i < flag.NArg(); i += 2 {
		k := flag.Arg(i)
		v := flag.Arg(i + 1)
		tag := map[string]string{"tagName": k, "tagValue": v}
		tags[idx] = tag
		idx++
	}
	fmt.Println(tags)

	c, err := goracom.NewClient(email, password)
	errToExit(err)
	s := c.NewSubscriber()
	sub, err := s.Tags(imsi, tags)
	errToExit(err)
	printSubscriber(*sub)
}
示例#2
0
文件: main.go 项目: CloudLife/go-fuse
func main() {
	// Scans the arg list and sets up flags
	debug := flag.Bool("debug", false, "print debugging messages.")
	latencies := flag.Bool("latencies", false, "record operation latencies.")

	flag.Parse()
	if flag.NArg() < 2 {
		fmt.Fprintf(os.Stderr, "usage: %s MOUNTPOINT ZIP-FILE\n", os.Args[0])
		os.Exit(2)
	}

	var fs fuse.NodeFileSystem
	fs, err := zipfs.NewArchiveFileSystem(flag.Arg(1))
	if err != nil {
		fmt.Fprintf(os.Stderr, "NewArchiveFileSystem failed: %v\n", err)
		os.Exit(1)
	}

	state, _, err := fuse.MountNodeFileSystem(flag.Arg(0), fs, nil)
	if err != nil {
		fmt.Printf("Mount fail: %v\n", err)
		os.Exit(1)
	}

	state.SetRecordStatistics(*latencies)
	state.Debug = *debug
	state.Loop()
}
示例#3
0
文件: archive.go 项目: grrtrr/clcv1
func main() {
	var acctAlias = flag.String("a", "", "Account alias to use")

	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: %s [options]  <HW Group UUID>\n", path.Base(os.Args[0]))
		flag.PrintDefaults()
	}

	flag.Parse()
	if flag.NArg() != 1 {
		flag.Usage()
		os.Exit(1)
	}

	client, err := clcv1.NewClient(log.New(os.Stdout, "", log.LstdFlags|log.Ltime))
	if err != nil {
		exit.Fatal(err.Error())
	} else if err := client.Logon("", ""); err != nil {
		exit.Fatalf("Login failed: %s", err)
	}

	reqId, err := client.ArchiveHardwareGroup(flag.Arg(0), *acctAlias)
	if err != nil {
		exit.Fatalf("Failed to archive Hardware Group %s: %s", flag.Arg(0), err)
	}

	fmt.Println("Request ID for group archival:", reqId)
}
示例#4
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		fmt.Println("Invalid E-Mail or Password\n")
		flag.Usage()
		os.Exit(-1)
	}

	if flag.NArg() != 2 {
		flag.Usage()
		os.Exit(-1)
	}
	imsi := flag.Arg(0)
	speed := flag.Arg(1)

	c, err := goracom.NewClient(email, password)
	errToExit(err)
	s := c.NewSubscriber()

	if sub, err := s.UpdateSpeedClass(imsi, speed); err == nil {
		printSubscriber(*sub)
	} else {
		errToExit(err)
	}
}
func main() {
	flag.Parse()
	root := flag.Arg(0)
	bucket = flag.Arg(1)
	conf = flag.Arg(2)
	filepath.Walk(root, walkpath)
}
示例#6
0
func main() {
	var versionFlg bool
	flag.BoolVar(&versionFlg, "v", false, "show version")
	flag.Parse()

	if versionFlg {
		fmt.Println("openstack-ssh version:", Version)
		return
	}
	if flag.Arg(0) == "" {
		panic("please input username")
	}
	config, err := app.LoadConfig()

	if err != nil {
		app.ERR(err)
		panic(err)
	}

	key, err := app.FetchPublicKey(flag.Arg(0), config)

	if err != nil {
		app.ERR(err)
		panic(err)
	}

	fmt.Println(key.PublicKey)
}
示例#7
0
文件: project.go 项目: pacur/pacur
func Project() (err error) {
	path, err := os.Getwd()
	if err != nil {
		err = &FileError{
			errors.Wrapf(err, "cmd: Failed to get working directory"),
		}
		return
	}

	proj := &project.Project{
		Root: path,
	}
	err = proj.Init()
	if err != nil {
		return
	}

	cmd := flag.Arg(1)
	switch cmd {
	case "init":
		err = proj.InitProject()
	case "build":
		err = proj.Build(flag.Arg(2))
	case "repo":
		err = proj.Repo(flag.Arg(2))
	default:
		err = &UnknownCommand{
			errors.Newf("cmd: Unknown cmd '%s'", cmd),
		}
	}

	return
}
示例#8
0
func main() {
	flag.Parse()

	if email == "" || password == "" {
		fmt.Println("Invalid E-Mail or Password\n")
		flag.Usage()
		os.Exit(-1)
	}

	if flag.NArg() != 2 {
		flag.Usage()
		os.Exit(-1)
	}
	imsi := flag.Arg(0)
	tm, err := strconv.ParseInt(flag.Arg(1), 10, 64)
	if err != nil {
		fmt.Printf("%s\n\n", err.Error())
		flag.Usage()
		os.Exit(-1)
	}

	c, err := goracom.NewClient(email, password)
	errToExit(err)
	s := c.NewSubscriber()
	if tm == 0 {
		sub, err := s.UnsetExpiryTime(imsi)
		errToExit(err)
		printSubscriber(*sub)
	} else {
		sub, err := s.SetExpiryTime(imsi, tm)
		errToExit(err)
		printSubscriber(*sub)
	}
}
示例#9
0
func main() {
	var pubFile, privFile string
	var help, listen, stayOpen bool
	flag.BoolVar(&help, "h", false, "display a short usage message")
	flag.BoolVar(&stayOpen, "k", false, "keep listening after client disconnects")
	flag.BoolVar(&listen, "l", false, "listen for incoming connections")
	flag.StringVar(&privFile, "s", "", "path to signature key")
	flag.StringVar(&pubFile, "v", "", "path to verification key")
	flag.Parse()

	if help {
		usage()
		os.Exit(1)
	}

	loadID(privFile, pubFile)
	defer func() {
		if idPriv != nil {
			zero(idPriv[:], 0)
		}
	}()

	if listen {
		if flag.NArg() != 1 {
			fmt.Println("A port is required (and should be the only argument) when listening.")
		}
		listener(stayOpen, flag.Arg(0))
		return
	}

	if flag.NArg() != 2 {
		fmt.Println("An address and port are required (and should be the only arguments).")
	}
	sender(flag.Arg(0) + ":" + flag.Arg(1))
}
示例#10
0
func main() {
	start := time.Now()

	flag.Parse()

	if *version {
		fmt.Printf("inspectFile %d.%d.%d\n", Version[0], Version[1], Version[2])
		return
	}
	if *flserve != "" {
		fmt.Printf("Startinf server at %s. Use CTRL+C to quit.\n", *flserve)
		listen(*flserve)
		return
	}
	if *fltools != "" {
		initTools(*fltools)
	}
	if *dir {
		if flag.NArg() != 1 {
			fmt.Println("You must pass a directory name!!!")
			return
		}
		inspectdir(flag.Arg(0))
	} else if flag.NArg() != 1 {
		fmt.Println("You must pass a file name in parameter!!!")
		return
	} else {
		output = inspectfile(flag.Arg(0), nil)
	}
	//output = inspectsfile("/media/sf_Temp/Benchmark.pptx", output)
	fmt.Printf("Output: %s \n", output)
	fmt.Printf("ToolsVersion: %s\n", ExportToolsVersion())

	fmt.Printf("Took %v to run.\n", time.Since(start))
}
示例#11
0
func main() {
	var acctAlias = flag.String("a", "", "Account alias to use")
	var snapName = flag.String("s", "", "The name of the Snapshot to delete")

	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: %s [options]  <server-name>\n", path.Base(os.Args[0]))
		flag.PrintDefaults()
	}

	flag.Parse()
	if flag.NArg() != 1 || *snapName == "" {
		flag.Usage()
		os.Exit(1)
	}

	client, err := clcv1.NewClient(log.New(os.Stdout, "", log.LstdFlags|log.Ltime))
	if err != nil {
		exit.Fatal(err.Error())
	} else if err := client.Logon("", ""); err != nil {
		exit.Fatalf("Login failed: %s", err)
	}

	err = client.DeleteSnapshot(*snapName, flag.Arg(0), *acctAlias)
	if err != nil {
		exit.Fatalf("Failed to delete snapshot on %s: %s", flag.Arg(0), err)
	}

	fmt.Printf("Successfully deleted snapshot %q from %s.\n", *snapName, flag.Arg(0))
}
示例#12
0
文件: main.go 项目: mhoc/msp
func main() {
	log.Trace("-m-", "Opening input file")

	// Parse debug flags
	flag.BoolVar(&log.LOG_TOKENS, "log-tokens", false, "Enable list of parsed tokens")
	flag.BoolVar(&log.LOG_TRACE, "log-trace", false, "Enable trace logging of debug output")
	flag.BoolVar(&log.EXTENSIONS, "extensions", false, "Enables parser extensions for additional features. See README for a list of these.")
	flag.Parse()

	// Init builtin functions
	ast.InitBuiltins()

	// Parse command line arguments
	var file *os.File
	var err error
	if flag.NArg() == 0 {
		log.Trace("-m-", "Reading from stdin")
		file = os.Stdin
	} else if flag.NArg() == 1 {
		log.Trace("-m-", "Reading from file "+flag.Arg(0))
		file, err = os.Open(flag.Arg(0))
	} else {
		panic("Must provide filename to read from or no filename at all")
	}

	if err != nil {
		panic("File name provided does not exist")
	}

	log.Trace("-m-", "Beginning lex")
	yyParse(NewLexer(file))

}
示例#13
0
文件: main.go 项目: scozssfork/mqtt
func main() {
	flag.Parse()

	if flag.NArg() != 2 {
		topic = "many"
		payload = proto.BytesPayload([]byte("hello"))
	} else {
		topic = flag.Arg(0)
		payload = proto.BytesPayload([]byte(flag.Arg(1)))
	}

	if *conns == 0 {
		*conns = -1
	}

	i := 0
	for {
		go client(i)
		i++

		*conns--
		if *conns == 0 {
			break
		}
		time.Sleep(time.Duration(*wait) * time.Millisecond)
	}

	// sleep forever
	<-make(chan struct{})
}
示例#14
0
// getFileHandles uses our arguments to set up our input and output files
func getFileHandles() (in, out *os.File, err error) {
	// Input file should be our only command line argument
	if len(flag.Args()) != 1 {
		err = fmt.Errorf("Must have exactly one argument (input filename).  Received: %v",
			flag.Args())
		return
	}
	in, err = os.Open(flag.Arg(0))
	if err != nil {
		err = fmt.Errorf("Error: Unable to open input file %v: %v", flag.Arg(0),
			err)
		return
	}

	// Output file
	out = os.Stdout
	if *output != "-" {
		out, err = os.Create(*output)
		if err != nil {
			err = fmt.Errorf("Error: Unable to open output file %v: %v", *output,
				err)
			return
		}
	}

	return
}
示例#15
0
func main() {
	search := flag.String("s", "", "search issues")
	create := flag.Bool("C", false, "create issue")
	comment := flag.Bool("c", false, "show comments")
	flag.Usage = func() {
		fmt.Fprint(os.Stderr, "Usage: goissue [-c ID | -s WORD]\n")
		flag.PrintDefaults()
	}
	flag.Parse()
	if flag.NArg() > 1 {
		flag.Usage()
		os.Exit(1)
	}

	config := getConfig()
	auth := authLogin(config)

	if *create {
		createIssue(auth)
	} else if len(*search) > 0 {
		searchIssues(auth, *search)
	} else if flag.NArg() == 0 {
		showIssues(auth)
	} else {
		for i := 0; i < flag.NArg(); i++ {
			showIssue(auth, flag.Arg(i))
			if *comment {
				showComments(auth, flag.Arg(i))
			}
		}
	}
}
示例#16
0
func main() {
	flag.Parse()

	c := client.NewHTTPClient(*address)
	if err := c.WaitUntilReady(*waitDuration); err != nil {
		log.Fatal(err)
	}

	serviceMethod, params := flag.Arg(0), json.RawMessage(flag.Arg(1))
	if *legacyCall {
		var resp json.RawMessage
		if err := c.Call(serviceMethod, &params, &resp); err != nil {
			log.Fatal(err)
		}
		fmt.Println(string(resp))
	} else {
		rd := c.Stream(serviceMethod, &params)
		defer rd.Close()
		for {
			var resp json.RawMessage
			if err := rd.NextResult(&resp); err == io.EOF {
				break
			} else if err != nil {
				log.Fatal(err)
			}
			fmt.Println(string(resp))
		}
	}
}
示例#17
0
func main() {
	flag.Parse()

	n, err := strconv.Atoi(flag.Arg(0))
	if err != nil {
		fmt.Printf("unknown number")
		return
	}

	c, err := strconv.Atoi(flag.Arg(1))
	if err != nil {
		fmt.Printf("unknown concurrent")
		return
	}

	ch_end := make(chan int, 100)

	for i := 0; i < c; i++ {
		go goroutine_gosched(n, ch_end)
	}

	for i := 0; i < c; i++ {
		<-ch_end
	}
	return
}
示例#18
0
func main() {
	var acctAlias = flag.String("a", "", "Account alias to use")

	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: %s [options]  <server-name>\n", path.Base(os.Args[0]))
		flag.PrintDefaults()
	}

	flag.Parse()

	if flag.NArg() != 1 {
		flag.Usage()
		os.Exit(1)
	}

	client, err := clcv1.NewClient(log.New(os.Stdout, "", log.LstdFlags|log.Ltime))
	if err != nil {
		exit.Fatal(err.Error())
	} else if err := client.Logon("", ""); err != nil {
		exit.Fatalf("Login failed: %s", err)
	}

	credentials, err := client.GetServerCredentials(flag.Arg(0), *acctAlias)
	if err != nil {
		exit.Fatalf("Failed to obtain the credentials of server %q: %s", flag.Arg(0), err)
	}

	fmt.Printf("Credentials for %s:\n", flag.Arg(0))
	fmt.Printf("User:     %s\n", credentials.Username)
	fmt.Printf("Password: '******'\n", credentials.Password)
}
示例#19
0
文件: main.go 项目: iwat/sftpsync
func main() {
	flag.Parse()
	if flag.NArg() != 1 && flag.NArg() != 2 {
		flag.Usage()
		fmt.Fprintf(os.Stderr, "Usage: %s <remote> [<local>]\n", os.Args[0])
		os.Exit(2)
	}

	handler := ext.FatalHandler(log15.CallerFileHandler(log15.StderrHandler))
	if flagVeryVerbose {
		handler = log15.LvlFilterHandler(log15.LvlDebug, handler)
	} else if flagVerbose {
		handler = log15.LvlFilterHandler(log15.LvlInfo, handler)
	}
	log15.Root().SetHandler(handler)

	local := "."
	if flag.NArg() == 2 {
		local = flag.Arg(1)
	}

	m := sftpsync.SyncManager{
		Local:     local,
		Remote:    flag.Arg(0),
		SkipFiles: skipFiles,
		SkipDirs:  skipDirs,
		Append:    flagAppend,
		DryRun:    flagDryRun,
	}
	err := m.Run()
	if err != nil {
		log.Crit("run error", "err", err)
		return
	}
}
示例#20
0
func main() {
	flag.Usage = usage
	flag.Parse()

	if flag.NArg() != 2 {
		flag.Usage()
		os.Exit(1)
	}

	serverAddr := flag.Arg(0)
	recordFilename := flag.Arg(1)

	recordInput, err := os.Open(recordFilename)
	if err != nil {
		log.Fatalf("Failed to open record file %q: %v", recordFilename, err)
	}
	defer recordInput.Close()

	conn, err := net.Dial("tcp", serverAddr)
	if err != nil {
		log.Fatalf("Failed to connect to server %q: %v", serverAddr, err)
	}
	defer conn.Close()

	replayer := record.NewReaderReplayer(recordInput, conn)
	// Discard everything the server sends us.
	go readAndDiscard(conn)
	replayer.Replay()
}
示例#21
0
func main() {
	flag.Parse()
	if flag.NArg() < 1 {
		usage()
	}

	id := ""
	if *iflag {
		id = "__initdata"
	}
	fmt.Printf("/* automatically generated by bin2hex */\n")
	fmt.Printf("static unsigned char %s[] %s =\n{\n\t", flag.Arg(0), id)

	i := uint64(0)
	for {
		var b [8192]byte

		n, err := os.Stdin.Read(b[:])
		for j := 0; j < n; j++ {
			c := b[j]
			if i != 0 && i%10 == 0 {
				fmt.Printf("\n\t")
			}
			i++
			fmt.Printf("%#02x,", c)
		}

		if err != nil {
			break
		}
	}

	fmt.Printf("\n};\nstatic int %sLen = %d;\n", flag.Arg(0), i)
}
示例#22
0
文件: main.go 项目: danny8002/go
func main() {
	flag.Usage = func() {
		fmt.Fprintln(os.Stderr, usageMessage)
		os.Exit(2)
	}
	flag.Parse()

	// Usage information when no arguments.
	if flag.NArg() != 2 {
		flag.Usage()
	}
	programBinary = flag.Arg(0)
	traceFile = flag.Arg(1)

	ln, err := net.Listen("tcp", *httpFlag)
	if err != nil {
		dief("failed to create server socket: %v\n", err)
	}
	// Open browser.
	if !startBrowser("http://" + ln.Addr().String()) {
		fmt.Fprintf(os.Stderr, "Trace viewer is listening on http://%s\n", ln.Addr().String())
	}

	// Parse and symbolize trace asynchronously while browser opens.
	go parseEvents()

	// Start http server.
	http.HandleFunc("/", httpMain)
	err = http.Serve(ln, nil)
	dief("failed to start http server: %v\n", err)
}
示例#23
0
文件: main.go 项目: splade/camlistore
// TODO(rh): tame copy/paste code from cammount
func main() {
	client.AddFlags()
	flag.Parse()
	cacheDir, err := ioutil.TempDir("", "camlicache")
	if err != nil {
		log.Fatalf("Error creating temp cache directory: %v", err)
	}
	defer os.RemoveAll(cacheDir)
	diskcache, err := localdisk.New(cacheDir)
	if err != nil {
		log.Fatalf("Error setting up local disk cache: %v", err)
	}
	if flag.NArg() != 1 {
		log.Fatal("usage: camwebdav <blobref>")
	}
	br := blobref.Parse(flag.Arg(0))
	if br == nil {
		log.Fatalf("%s was not a valid blobref.", flag.Arg(0))
	}
	client := client.NewOrFail()
	fetcher := cacher.NewCachingFetcher(diskcache, client)

	f = fs.NewCamliFileSystem(fetcher, br)
	http.HandleFunc("/", webdav)
	err = http.ListenAndServe(*davaddr, nil)
	if err != nil {
		log.Fatalf("Error starting WebDAV server: %v", err)
	}
}
示例#24
0
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s <command> [command-opts]\n", os.Args[0])
		fmt.Fprintln(os.Stderr, "Commands:")
		for cmd, _ := range Commands {
			fmt.Fprintf(os.Stderr, "  %s\n", cmd)
		}
	}
	flag.Parse()
	if flag.NArg() < 1 {
		flag.Usage()
		os.Exit(1)
	}

	subcommand := flag.Arg(0)

	if cmd, in := Commands[subcommand]; in {
		flags := flag.NewFlagSet(Cmd_Repo, flag.ExitOnError)
		cmd(os.Args[1:], flags)
		os.Exit(0)
	}

	fmt.Fprintf(os.Stderr, "Subcommand not recognized: %s\n", flag.Arg(0))
	flag.Usage()
	os.Exit(1)
}
示例#25
0
文件: duosum.go 项目: sybrandy/duosum
func main() {
	// Get the name of the file.
	flag.Parse()
	fmt.Fprintf(os.Stdout, "Filename: %s\n", flag.Arg(0))

	// Slurp the file into a string.
	file, err := ioutil.ReadFile(flag.Arg(0))
	if err != nil {
		fmt.Fprintf(os.Stdout, "Error reading the file: %s", err.String())
		os.Exit(1)
	}

	// Create the MD5 hash.
	digest1 := md5.New()
	_, err = digest1.Write(file)
	if err != nil {
		fmt.Fprintf(os.Stdout, "Error creating the first hash: %s\n", err.String())
		os.Exit(1)
	}
	fmt.Fprintf(os.Stdout, "MD5: %x\n", digest1.Sum())

	// Create the SHA-1 hash.
	digest2 := sha1.New()
	_, err = digest2.Write(file)
	if err != nil {
		fmt.Fprintf(os.Stdout, "Error creating the first hash: %s\n", err.String())
		os.Exit(1)
	}
	fmt.Fprintf(os.Stdout, "SHA-1: %x\n", digest2.Sum())
}
示例#26
0
文件: gfind.go 项目: kiyor/gfind
func InitFindConfByFlag() gfind.FindConf {
	var conf gfind.FindConf
	if flag.Arg(0) != "" {
		fmt.Println(flag.Arg(0))
		conf.Dir = flag.Arg(0)
	} else {
		conf.Dir = *dir
	}
	conf.Stat = new(syscall.Stat_t)
	conf.Maxdepth = *fmaxdepth

	conf.Ctime = *fctime
	conf.Cmin = *fcmin
	conf.Mtime = *fmtime
	conf.Mmin = *fmmin
	conf.Atime = *fatime
	conf.Amin = *famin
	conf.ParseCMTime()
	conf.RevTime = *frevtime

	conf.Ftype = *fftype
	conf.Name = *fname
	conf.Ext = *fext
	conf.Rootdir = *root
	conf.SetRootdir()
	if *frsynctemp {
		conf.RsyncTemp = 1
	}

	conf.FlatSize = *fsize
	conf.ParseSize()

	return conf
}
示例#27
0
文件: gorep.go 项目: ryochack/gorep
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	var opt optionSet
	flag.BoolVar(&opt.v, "V", false, "show version.")
	flag.BoolVar(&opt.g, "g", false, "enable grep.")
	flag.BoolVar(&opt.search_binary, "search-binary", false, "search binary files for matches on grep enable.")
	flag.BoolVar(&opt.grep_only, "grep-only", false, "enable grep and disable file search.")
	flag.StringVar(&opt.ignore, "ignore", "", "pattern is ignored.")
	flag.BoolVar(&opt.hidden, "hidden", false, "search hidden files.")
	flag.BoolVar(&opt.ignorecase, "ignorecase", false, "ignore case distinctions in pattern.")
	flag.Parse()

	if opt.v {
		fmt.Printf("version: %s\n", version)
		os.Exit(0)
	}

	if flag.NArg() < 1 {
		usage()
	}
	pattern := flag.Arg(0)
	fpath := "."
	if flag.NArg() >= 2 {
		fpath = strings.TrimRight(flag.Arg(1), separator)
	}

	g := newGorep(pattern, &opt)
	chans := g.kick(fpath)

	g.report(chans, verifyColor())
}
示例#28
0
func main() {
	flag.Parse()

	imagick.Initialize()
	defer imagick.Terminate()
	mw := imagick.NewMagickWand()
	defer mw.Destroy()
	var err error

	if flag.NArg() < 1 {
		fmt.Println("Usage: imagick_profiles <imgfile> [<proftype>]\n")
		os.Exit(1)
	}
	basename := flag.Arg(0)
	err = mw.ReadImage(basename)
	if err != nil {
		fmt.Println("ReadImage Error:", err)
		os.Exit(1)
	}
	if flag.NArg() == 1 {
		profs := mw.GetImageProfiles("*")
		fmt.Println(profs)
	} else {
		proftype := flag.Arg(1)
		prof := mw.GetImageProfile(proftype)
		fmt.Print(prof)
	}
}
示例#29
0
文件: main.go 项目: kisielk/vendorize
func main() {
	flag.BoolVar(&fake, "n", false, "If true, don't actually do anything")
	flag.BoolVar(&verbose, "v", false, "Provide verbose output")
	flag.Var(&ignorePrefixes, "ignore", "Package prefix to ignore. Can be given multiple times.")
	flag.Parse()

	gopaths := filepath.SplitList(os.Getenv("GOPATH"))
	if len(gopaths) == 0 {
		log.Fatal("GOPATH must be set")
	}
	pkgName := flag.Arg(0)
	if pkgName == "" {
		log.Fatal("need a package name")
	}
	dest := flag.Arg(1)
	if dest == "" {
		log.Fatal("need a destination path")
	}

	ignorePrefixes = append(ignorePrefixes, pkgName)
	ignorePrefixes = append(ignorePrefixes, dest)
	rewrites = make(map[string]string)
	visited = make(map[string]bool)

	err := vendorize(pkgName, chooseGOPATH(gopaths, dest), dest)
	if err != nil {
		log.Fatal(err)
	}
}
示例#30
0
func main() {
	log.SetFlags(0)
	log.SetPrefix("power64map: ")

	flag.Usage = usage
	flag.Parse()
	if flag.NArg() != 1 {
		usage()
	}

	inputFile = flag.Arg(0)

	var print func(*Prog)
	switch *format {
	default:
		log.Fatalf("unknown output format %q", *format)
	case "text":
		print = printText
	case "decoder":
		print = printDecoder
	}

	p, err := readCSV(flag.Arg(0))
	log.Printf("Parsed %d instruction forms.", len(p.Insts))
	if err != nil {
		log.Fatal(err)
	}

	print(p)
}