本文整理汇总了Golang中flag.Usage函数的典型用法代码示例。如果您正苦于以下问题:Golang Usage函数的具体用法?Golang Usage怎么用?Golang Usage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Usage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
flag.Usage = Usage
flag.Parse()
if *showVersion {
fmt.Println("goobar", Version)
os.Exit(0)
}
if *listenAddress == "" {
fmt.Fprintln(os.Stderr, "you must supply an address to listen on")
flag.Usage()
os.Exit(1)
}
if *memcacheBackend == "" {
fmt.Fprintln(os.Stderr, "you must specify a memcached backend")
flag.Usage()
os.Exit(1)
}
log.SetPrefix("goobar ")
log.SetFlags(log.Ldate | log.Lmicroseconds)
tsock, err := net.Listen("tcp", *listenAddress)
if err != nil {
panic(err)
}
server.Main(tsock)
}
开发者ID:sofuture,项目名称:goobar,代码行数:31,代码来源:goobar.go
示例2: main
func main() {
flag.Usage = usage
flag.Parse()
cachingHTTPClient = util.CachingHttpClient()
if *tokenFlag == "" || cachingHTTPClient == nil {
flag.Usage()
return
}
ds = clientFlags.CreateDataset()
if ds == nil {
flag.Usage()
return
}
defer ds.Store().Close()
if err := clientFlags.CreateProgressFile(); err != nil {
fmt.Println(err)
} else {
defer clientFlags.CloseProgressFile()
}
token := oauth2.Token{AccessToken: *tokenFlag}
authHTTPClient = oauth2.NewClient(oauth2.NoContext, oauth2.StaticTokenSource(&token))
start = time.Now()
var user = getUser()
printStats(user)
userRef := ds.Store().WriteValue(user)
fmt.Printf("userRef: %s\n", userRef.TargetRef())
_, err := ds.Commit(userRef)
d.Exp.NoError(err)
}
开发者ID:arv,项目名称:noms-old,代码行数:35,代码来源:facebook.go
示例3: main
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s size\n", os.Args[0])
fmt.Fprintf(os.Stderr, " Must specify an odd integer for size\n")
flag.PrintDefaults()
}
flag.Parse()
if flag.NArg() != 1 {
flag.Usage()
return
}
size, err := strconv.Atoi(flag.Arg(0))
if err != nil {
flag.Usage()
return
}
square, err := magicsquare.MagicSquare(size)
if err != nil {
flag.Usage()
return
}
for _, row := range square {
for _, col := range row {
fmt.Printf("%5v", col)
}
fmt.Printf("\n")
}
}
开发者ID:jmcvetta,项目名称:magicsquare,代码行数:29,代码来源:main.go
示例4: cmdCreateTeam
func cmdCreateTeam() {
if flagCmdCreateTeam {
if len(flagTeamName) == 0 {
fmt.Fprintln(os.Stderr, "flag needs an argument: -team_name")
flag.Usage()
os.Exit(1)
}
if len(flagEmail) == 0 {
fmt.Fprintln(os.Stderr, "flag needs an argument: -email")
flag.Usage()
os.Exit(1)
}
c := &api.Context{}
c.RequestId = model.NewId()
c.IpAddress = "cmd_line"
team := &model.Team{}
team.DisplayName = flagTeamName
team.Name = flagTeamName
team.Email = flagEmail
team.Type = model.TEAM_INVITE
api.CreateTeam(c, team)
if c.Err != nil {
if c.Err.Message != "A team with that domain already exists" {
l4g.Error("%v", c.Err)
flushLogAndExit(1)
}
}
os.Exit(0)
}
}
开发者ID:cbayleOL,项目名称:platform,代码行数:35,代码来源:mattermost.go
示例5: main
// Remember Exit(0) is success, Exit(1) is failure
func main() {
flag.Var(&slaveList, "control", "list of ip:port addresses to control")
flag.Parse()
if len(*testUrl) == 0 {
flag.Usage()
os.Exit(1)
}
if len(slaveList) > 0 && *listen != 0 {
fmt.Fprintf(os.Stderr, "You can't have both --listen and --control flags")
flag.Usage()
os.Exit(1)
}
rand.Seed(time.Now().Unix())
// set up logging
logWriter, err := os.OpenFile(*logFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
println(err)
os.Exit(1)
}
log.SetOutput(logWriter)
TRACE = log.New(ioutil.Discard,
"TRACE: ",
log.Ldate|log.Ltime|log.Lshortfile)
INFO = log.New(logWriter,
"INFO: ",
log.Ldate|log.Ltime|log.Lshortfile)
ERROR = log.New(logWriter,
"ERROR: ",
log.Ldate|log.Ltime|log.Lshortfile)
INFO.Println("beginning run")
os.Exit(realMain())
}
开发者ID:kgoess,项目名称:webserver-loadtest,代码行数:36,代码来源:webserver-loadtest.go
示例6: main
func main() {
token := os.Getenv("GITHUB_ACCESS_TOKEN")
client := github.NewClient(token)
flag.Usage = func() { fmt.Print(usage) }
flag.Parse()
args := flag.Args()
if len(args) == 0 {
flag.Usage()
os.Exit(1)
}
switch args[0] {
case "create":
create(client, args[1:])
case "show":
show(client, args[1:])
case "search":
search(client, args[1:])
case "edit":
edit(client, args[1:])
case "close":
close(client, args[1:])
case "reopen":
reopen(client, args[1:])
default:
flag.Usage()
os.Exit(1)
}
}
开发者ID:seikichi,项目名称:gopl,代码行数:30,代码来源:issues.go
示例7: commands
func commands(args []string) {
var cfg config
var err error
fmt.Println(args)
if len(args) == 0 {
flag.Usage()
return
}
switch args[0] {
case "new":
path := args[1]
if path == "" {
flag.Usage()
os.Exit(1)
}
err = cfg.New(path)
checkFatal(err)
case "build":
err = cfg.load("_config.yml")
checkFatal(err)
err = cfg.Build()
checkFatal(err)
case "serve":
err = cfg.load("_config.yml")
checkFatal(err)
err = cfg.Serve()
checkFatal(err)
default:
flag.Usage()
}
}
开发者ID:NovemberFoxtrot,项目名称:jedie,代码行数:34,代码来源:jedie.go
示例8: init
func init() {
flag.StringVar(&in, "in", "", "BAM file to be processed.")
flag.StringVar(&annot, "annot", "", "file name of a GFF file containing annotations.")
flag.Float64Var(&thresh, "thresh", 1, "log score threshold for inclusion of feature.")
flag.Var(&classes, "class", "comma separated set of annotation classes to analyse.")
flag.BoolVar(&pretty, "pretty", true, "outfile JSON data indented.")
flag.IntVar(&minLength, "min", 20, "minimum length read considered.")
flag.IntVar(&maxLength, "max", 35, "maximum length read considered.")
flag.IntVar(&minId, "minid", 90, "minimum percentage identity for mapped bases.")
flag.IntVar(&minQ, "minQ", 20, "minimum per-base sequence quality.")
flag.Float64Var(&minAvQ, "minAvQ", 30, "minimum average per-base sequence quality.")
flag.IntVar(&mapQ, "mapQ", 0, "minimum mapping quality [0, 255).")
flag.IntVar(&binLength, "bin", 1e7, "bin length.")
help := flag.Bool("help", false, "output this usage message.")
flag.Parse()
mapQb = byte(mapQ)
if *help {
flag.Usage()
os.Exit(0)
}
if in == "" || !annotOK(annot, classes) || mapQ < 0 || mapQ > 254 {
flag.Usage()
os.Exit(1)
}
}
开发者ID:henmt,项目名称:2015,代码行数:25,代码来源:trans-diff.go
示例9: main
func main() {
help := flag.Bool("help", false, "show this message")
inFile := flag.String("in", "", "input filename (required)")
outFile := flag.String("out", "", "output filename (stdout if omitted)")
flag.Parse()
if *help {
flag.Usage()
os.Exit(0)
}
if len(*inFile) == 0 {
flag.Usage()
os.Exit(0)
}
pr := codejam.NewProblem(*inFile, *outFile)
numTestCases := pr.ReadInt()
if numTestCases < 1 {
panic(fmt.Errorf("no testcases available"))
}
for testIndex := 1; testIndex <= numTestCases; testIndex++ {
d := parse(pr, testIndex)
solve(pr, d)
}
pr.Close()
}
开发者ID:uwedeportivo,项目名称:codejam,代码行数:32,代码来源:main.go
示例10: cmdAssignRole
func cmdAssignRole() {
if flagCmdAssignRole {
if len(flagEmail) == 0 {
fmt.Fprintln(os.Stderr, "flag needs an argument: -email")
flag.Usage()
os.Exit(1)
}
if !model.IsValidUserRoles(flagRole) {
fmt.Fprintln(os.Stderr, "flag invalid argument: -role")
flag.Usage()
os.Exit(1)
}
c := getMockContext()
var user *model.User
if result := <-api.Srv.Store.User().GetByEmail(flagEmail); result.Err != nil {
l4g.Error("%v", result.Err)
flushLogAndExit(1)
} else {
user = result.Data.(*model.User)
}
if !user.IsInRole(flagRole) {
api.UpdateUserRoles(c, user, flagRole)
}
os.Exit(0)
}
}
开发者ID:lfbrock,项目名称:platform,代码行数:31,代码来源:mattermost.go
示例11: realMain
func realMain() int {
flag.Parse()
if help {
flag.Usage()
fmt.Fprint(os.Stderr, "Flags:\n")
fmt.Fprint(os.Stderr, "\n")
flag.PrintDefaults()
return 0
}
worker.files = flag.Args() // this is the list of files
if len(worker.files) == 0 {
flag.Usage()
return 1
}
err := worker.Work()
if err != nil {
if err == ErrProcess {
return len(worker.errs) // the number of operations (files) that errored is the return code
}
return 1
}
return 0
}
开发者ID:mohae,项目名称:peu,代码行数:25,代码来源:main.go
示例12: cmdCreateTeam
func cmdCreateTeam() {
if flagCmdCreateTeam {
if len(flagTeamName) == 0 {
fmt.Fprintln(os.Stderr, "flag needs an argument: -team_name")
flag.Usage()
os.Exit(1)
}
if len(flagEmail) == 0 {
fmt.Fprintln(os.Stderr, "flag needs an argument: -email")
flag.Usage()
os.Exit(1)
}
c := getMockContext()
team := &model.Team{}
team.DisplayName = flagTeamName
team.Name = flagTeamName
team.Email = flagEmail
team.Type = model.TEAM_OPEN
api.CreateTeam(c, team)
if c.Err != nil {
if c.Err.Id != "store.sql_team.save.domain_exists.app_error" {
l4g.Error("%v", c.Err)
flushLogAndExit(1)
}
}
os.Exit(0)
}
}
开发者ID:lfbrock,项目名称:platform,代码行数:33,代码来源:mattermost.go
示例13: main
func main() {
var ihelp *bool = flag.Bool("h", false, "Print help information")
var iport *int = flag.Int("p", 6666, "Port number")
var iverb *int = flag.Int("v", 1, "Verbosity (0-6)")
var idrop *int = flag.Int("r", 0, "Network packet drop percentage")
var elim *int = flag.Int("k", 5, "Epoch limit")
var ems *int = flag.Int("d", 2000, "Epoch duration (millisecconds)")
flag.Parse()
if *ihelp {
flag.Usage()
os.Exit(0)
}
var port int = *iport
if flag.NArg() > 0 {
nread, _ := fmt.Sscanf(flag.Arg(0), "%d", &port)
if nread != 1 {
flag.Usage()
os.Exit(0)
}
}
params := &lsp12.LspParams{*elim, *ems}
lsplog.SetVerbose(*iverb)
lspnet.SetWriteDropPercent(*idrop)
fmt.Printf("Establishing server on port %d\n", port)
srv, err := lsp12.NewLspServer(port, params)
if err != nil {
fmt.Printf("... failed. Error message %s\n", err.Error())
} else {
runserver(srv)
}
}
开发者ID:ammarar,项目名称:DecentralizedLoadBalancer,代码行数:32,代码来源:echoserver.go
示例14: main
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)
protection := flag.Arg(1)
c, err := goracom.NewClient(email, password)
errToExit(err)
s := c.NewSubscriber()
if protection == "false" {
sub, err := s.EnableTerminate(imsi)
errToExit(err)
printSubscriber(*sub)
} else {
sub, err := s.DisableTerminate(imsi)
errToExit(err)
printSubscriber(*sub)
}
}
开发者ID:135yshr,项目名称:goracom,代码行数:29,代码来源:terminate.go
示例15: main
func main() {
flag.Parse()
if helpFlag {
flag.Usage()
os.Exit(0)
}
if len(upstreamUrl) == 0 {
fmt.Println("Missing argument -upstream")
flag.Usage()
os.Exit(1)
}
if len(dataplaneUrl) == 0 {
fmt.Println("Missing argument -dataplane")
flag.Usage()
os.Exit(1)
}
notifier := gbp.NewNotifier(upstreamUrl, listenSocket)
if err := notifier.NotifyEndpointUp(); err != nil {
fmt.Println(err)
os.Exit(1)
}
g, err := gbp.NewServer(upstreamUrl, dataplaneUrl)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
gbp.Info.Printf("GBP Server listening on %s\n", listenSocket)
http.ListenAndServe(listenSocket, g.Handler())
}
开发者ID:iovisor,项目名称:iomodules,代码行数:29,代码来源:main.go
示例16: main
func main() {
log.SetFlags(0)
flag.Parse()
// Set the data directory.
if flag.NArg() == 0 {
flag.Usage()
log.Fatal("Data path argument required")
}
if *stop == 0 {
flag.Usage()
log.Fatal("stop commit is required")
}
dbpath := flag.Arg(0)
client := cluster.NewLocalClient("http://"+*node, 1)
meta, err := client.StreamsMetadata()
if err != nil {
log.Fatal(err)
}
err = cluster.Clear(dbpath, *stop, meta.Closed)
if err != nil {
log.Fatal(err)
}
}
开发者ID:jmptrader,项目名称:esdb,代码行数:30,代码来源:main.go
示例17: main
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)
}
开发者ID:135yshr,项目名称:goracom,代码行数:32,代码来源:set_tag.go
示例18: main
func main() {
create := flag.Bool("create", false, "create shares from a secret")
minimum := flag.Int("minimum", 3, "minimum shares required to recreate secret")
shares := flag.Int("shares", 4, "total shares to create (shares >= minimum)")
secret := flag.String("secret", "Hello, World!", "secret to share")
combine := flag.Bool("combine", false, "combines shares into a secret")
raw := flag.String("secrets", "", "comma separated list of shared secrets")
flag.Parse()
if *create == *combine {
flag.Usage()
} else if *create {
if *minimum > *shares {
flag.Usage()
} else {
values := sssa.Create(*minimum, *shares, *secret)
for i := range values {
fmt.Println(values[i])
}
}
} else {
if *raw == "" {
flag.Usage()
} else {
secrets := strings.Split(*raw, ",")
value := sssa.Combine(secrets)
fmt.Println("Secret: ", value)
}
}
}
开发者ID:SSSaaS,项目名称:sssaas-cli,代码行数:31,代码来源:sssaas-cli.go
示例19: main
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)
}
}
开发者ID:135yshr,项目名称:goracom,代码行数:34,代码来源:expiry_time.go
示例20: init
func init() {
flag.StringVar(&in, "in", "", "file name of a BAM file to be processed.")
flag.StringVar(&annot, "annot", "", "file name of a GFF file containing annotations.")
flag.Var(&classes, "class", "comma separated set of annotation classes to analyse.")
flag.StringVar(&out, "out", "", "outfile name.")
flag.IntVar(&minLength, "min", 20, "minimum length read considered.")
flag.IntVar(&maxLength, "max", 35, "maximum length read considered.")
flag.IntVar(&minId, "minid", 90, "minimum percentage identity for non-clipped bases.")
flag.IntVar(&minQ, "minQ", 20, "minimum per-base sequence quality.")
flag.IntVar(&filter, "f", 0, "filter on piwi type 0: no filter, 1: primary, 2: secondary.")
flag.Float64Var(&minAvQ, "minAvQ", 30, "minimum average per-base sequence quality.")
flag.IntVar(&mapQ, "mapQ", 0, "minimum mapping quality [0, 255).")
flag.IntVar(&binLength, "bin", 1e7, "bin length.")
flag.StringVar(&format, "format", "svg", "specifies the output format of the example: eps, jpg, jpeg, pdf, png, svg, and tiff.")
help := flag.Bool("help", false, "output this usage message.")
flag.Parse()
mapQb = byte(mapQ)
if *help {
flag.Usage()
os.Exit(0)
}
if in == "" || out == "" || annot == "" || len(classes) == 0 || mapQ < 0 || mapQ > 254 {
flag.Usage()
os.Exit(1)
}
for _, s := range []string{"eps", "jpg", "jpeg", "pdf", "png", "svg", "tiff"} {
if format == s {
return
}
}
flag.Usage()
os.Exit(1)
}
开发者ID:henmt,项目名称:2015,代码行数:33,代码来源:length-heat-annot.go
注:本文中的flag.Usage函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论