• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang v2.Parse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中gopkg/in/alecthomas/kingpin/v2.Parse函数的典型用法代码示例。如果您正苦于以下问题:Golang Parse函数的具体用法?Golang Parse怎么用?Golang Parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Parse函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	kingpin.Parse()
	if !contains(availableThemes, *theme) {
		kingpin.Fatalf("theme: %s not found", *theme)
	}

	p, err := presentation.NewFromFileWithConfig(*source, *config)
	ifErrFatal(err)

	p.Theme = *theme

	if *startDaemon {
		r := mux.NewRouter()

		r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
			ifErrFatal(p.Write(w))
			if err := p.Reload(); err != nil {
				w.WriteHeader(http.StatusInternalServerError)
			}
		})

		r.PathPrefix("/").Handler(http.FileServer(http.Dir(".")))

		port := ":" + strconv.Itoa(*port)
		log.Println("Serving slides at", port)
		log.Fatal(http.ListenAndServe(port, r))

		return
	}

	// Write it just if we don't serve it
	ifErrFatal(p.Write(*outputFile))
}
开发者ID:strogo,项目名称:md2slides,代码行数:33,代码来源:main.go


示例2: main

func main() {
	kingpin.Parse()

	if *startDaemon {
		debug, _ = strconv.ParseBool(os.Getenv("DEBUG"))
		rules, _ = loadRulesFromFile("rules.yaml")
		log.Println("Daemon is listening in port", strconv.Itoa(*port))
		http.HandleFunc("/validate", validateHandler)
		http.HandleFunc("/setup", uploadHandler)
		http.HandleFunc("/rules", uploadRulesHandler)
		http.HandleFunc("/", defaultHandler)
		http.ListenAndServe(":8080", nil)

	} else {
		rules, _ = loadRulesFromFile(*rulesFile)
		dfile, _ := DockerfileFromPath(*dockerfile)

		v := Validation{rules, dfile}
		valid, msg := v.validate()
		if valid {
			fmt.Println("Dockerfile valid")
			os.Exit(0)
		} else {
			fmt.Println("Docker file not vallid:", msg)
			os.Exit(1)
		}

	}
}
开发者ID:UKHomeOffice,项目名称:dockerfile-validator,代码行数:29,代码来源:main.go


示例3: main

func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()

	password := randPass()

	var details artifactory.UserDetails = artifactory.UserDetails{
		Email:    *email,
		Password: password,
	}
	if group != nil {
		details.Groups = *group
	}

	if updatable != nil {
		details.ProfileUpdatable = *updatable
	}
	err := client.CreateUser(*username, details)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		if *showpass {
			fmt.Printf("User created. Random password is: %s\n", password)
		}
		os.Exit(0)
	}
}
开发者ID:lusis,项目名称:go-artifactory,代码行数:28,代码来源:main.go


示例4: main

func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	data, err := client.GetRepos(*kind)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{
			"Key",
			"Type",
			"Description",
			"Url",
		})
		for _, r := range data {
			table.Append([]string{
				r.Key,
				r.Rtype,
				r.Description,
				r.Url,
			})
		}
		table.Render()
		os.Exit(0)
	}
}
开发者ID:jblaine,项目名称:go-artifactory,代码行数:27,代码来源:main.go


示例5: main

func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	data, err := client.GetJob(*jobid)
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		scope := data.Job
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"ID", "Name", "Description", "Group", "Steps", "Node Filters"})
		var steps []string
		var nodefilters []string
		for _, d := range scope.Sequence.Steps {
			var stepDescription string
			if d.Description == "" {
				if d.JobRef != nil {
					stepDescription = d.JobRef.Name
				} else if d.Exec != nil {
					stepDescription = *d.Exec
				}
			} else {
				stepDescription = d.Description
			}
			steps = append(steps, stepDescription)
		}
		for _, n := range scope.NodeFilters.Filter {
			nodefilters = append(nodefilters, n)
		}
		table.Append([]string{scope.ID, scope.Name, scope.Description, scope.Group, strings.Join(steps, "\n"), strings.Join(nodefilters, "\n")})
		table.Render()
	}
}
开发者ID:ephemeral972,项目名称:go-rundeck,代码行数:32,代码来源:main.go


示例6: main

func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	u, err := client.GetUserDetails(*user)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"Name", "Email", "Password", "Admin?", "Updatable?", "Last Logged In", "Internal Password Disabled?", "Realm", "Groups"})
		table.SetAutoWrapText(false)
		table.Append([]string{
			u.Name,
			u.Email,
			"<hidden>",
			strconv.FormatBool(u.Admin),
			strconv.FormatBool(u.ProfileUpdatable),
			u.LastLoggedIn,
			strconv.FormatBool(u.InternalPasswordDisabled),
			u.Realm,
			strings.Join(u.Groups, "\n"),
		})
		table.Render()
		os.Exit(0)
	}
}
开发者ID:ttekin,项目名称:go-artifactory,代码行数:26,代码来源:main.go


示例7: init

func init() {
	flag.Parse()
	config.SetConfigFile(*configFileName)

	err := config.ReadInConfig()
	if err != nil {
		panic("Config file not found")
	}
	logConfig := config.GetStringMap("log")
	initLog(logConfig)
}
开发者ID:artpar,项目名称:greconcile,代码行数:11,代码来源:main.go


示例8: main

func main() {
	kingpin.Version("0.1.1")
	kingpin.Parse()
	forwardEnabled := false
	if *forwardhost != "" && *forwardport != "" {
		forwardEnabled = true
	}
	log.Println("Clenaup interval ", *cleanupInterval)

	serve(&MailServer{hostname: *hostname, port: *port, httpport: *webport, forwardEnabled: forwardEnabled, forwardHost: *forwardhost, forwardPort: *forwardport, expireinterval: *cleanupInterval})
}
开发者ID:digibib,项目名称:gosmtpd,代码行数:11,代码来源:main.go


示例9: main

func main() {

	fmt.Println(buildInfo())

	kingpin.Parse()

	if *configPath == "" {
		*configPath = "/etc/tinfoilhat/tinfoilhat.toml"
	}

	config, err := config.ReadConfig(*configPath)
	if err != nil {
		log.Fatalln("Cannot open config:", err)
	}

	db, err := steward.OpenDatabase(config.Database.Connection)
	if err != nil {
		log.Fatalln("Open database fail:", err)
	}

	defer db.Close()

	db.SetMaxOpenConns(config.Database.MaxConnections)

	switch kingpin.Parse() {
	case "advisory list":
		advisoryList(db)

	case "advisory review":
		advisoryReview(db)

	case "advisory hide":
		advisoryHide(db)

	case "advisory unhide":
		advisoryUnhide(db)

	case "scoreboard":
		scoreboardShow(db)
	}
}
开发者ID:jollheef,项目名称:tin_foil_hat,代码行数:41,代码来源:main.go


示例10: main

func main() {

	fmt.Println(buildInfo())

	kingpin.Parse()

	if *configPath == "" {
		log.Println("Use default config path")
		*configPath = "/etc/tinfoilhat/tinfoilhat.toml"
	}

	config, err := config.ReadConfig(*configPath)
	if err != nil {
		log.Fatalln("Cannot open config:", err)
	}

	logFile, err := os.OpenFile(config.LogFile,
		os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
	if err != nil {
		log.Fatalln("Cannot open file:", err)
	}
	defer logFile.Close()
	log.SetOutput(logFile)

	log.Println(buildInfo())

	var rlim syscall.Rlimit
	err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim)
	if err != nil {
		log.Fatalln("Getrlimit fail:", err)
	}

	log.Println("RLIMIT_NOFILE CUR:", rlim.Cur, "MAX:", rlim.Max)

	db, err := steward.OpenDatabase(config.Database.Connection)
	if err != nil {
		log.Fatalln("Open database fail:", err)
	}

	defer db.Close()

	db.SetMaxOpenConns(config.Database.MaxConnections)

	if *dbReinit {
		reinitDatabase(db, config)
	}

	checker.SetTimeout(config.CheckerTimeout.Duration)

	if config.AdvisoryReceiver.Disabled {
		scoreboard.DisableAdvisory()
	}

	priv, err := vexillary.GenerateKey()
	if err != nil {
		log.Fatalln("Generate key fail:", err)
	}

	attackFlow := make(chan scoreboard.Attack, config.API.AttackBuffer)

	go receiver.FlagReceiver(db, priv, config.FlagReceiver.Addr,
		config.FlagReceiver.ReceiveTimeout.Duration,
		config.FlagReceiver.SocketTimeout.Duration,
		attackFlow)

	go receiver.AdvisoryReceiver(db, config.AdvisoryReceiver.Addr,
		config.AdvisoryReceiver.ReceiveTimeout.Duration,
		config.AdvisoryReceiver.SocketTimeout.Duration)

	go scoreboard.Scoreboard(db, attackFlow,
		config.Scoreboard.WwwPath,
		config.Scoreboard.Addr,
		config.Scoreboard.UpdateTimeout.Duration,
		config.Pulse.Start.Time,
		config.Pulse.Half.Duration,
		config.Pulse.Lunch.Duration,
		config.Pulse.DarkestTime.Duration)

	err = pulse.Pulse(db, priv,
		config.Pulse.Start.Time,
		config.Pulse.Half.Duration,
		config.Pulse.Lunch.Duration,
		config.Pulse.RoundLen.Duration,
		config.Pulse.CheckTimeout.Duration)
	if err != nil {
		log.Fatalln("Game error:", err)
	}

	log.Println("It's now safe to turn off you computer")
	for {
		time.Sleep(time.Hour)
	}
}
开发者ID:jollheef,项目名称:tin_foil_hat,代码行数:93,代码来源:main.go



注:本文中的gopkg/in/alecthomas/kingpin/v2.Parse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang v2.Application类代码示例发布时间:2022-05-28
下一篇:
Golang v2.Arg函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap