本文整理匯總了Golang中github.com/ogier/pflag.BoolVarP函數的典型用法代碼示例。如果您正苦於以下問題:Golang BoolVarP函數的具體用法?Golang BoolVarP怎麽用?Golang BoolVarP使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BoolVarP函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
func init() {
flag.BoolVarP(&Version, "version", "v", false,
"Output the current version of the application.")
flag.StringVarP(&WorkingDir, "working-dir", "w", "./",
"The directory where all the other directories reside. This "+
"will be prepended to the rest of the configurable directories.")
flag.StringVarP(&OutputDir, "output-dir", "o", "public",
"The directory where the results should be placed.")
flag.BoolVarP(&EmptyOutputDir, "empty-output-dir", "x", false,
"Before writing to the output-dir, delete anything inside of it.")
flag.StringVarP(&TemplateDir, "template-dir", "t", "templates",
"The directory where the site templates are located.")
flag.StringVarP(&BlogDir, "blog-dir", "b", "blogs",
"The directory where the blogs are located.")
flag.StringVarP(&StaticDir, "static-dir", "s", "static",
"The directory where the static assets are located.")
flag.StringVarP(&URL, "url", "u", "",
"The url to be prepended to link in the RSS feed. Defaults to "+
"the value in the channel <link>.")
flag.IntVarP(&MaxIndexEntries, "index-entries", "i", 3,
"The maximum number of entries to display on the index page.")
}
示例2: main
// Start the game and then, based on command line input, start up client
// interface listeners. Finally, wait for ^C before exiting.
func main() {
var local, serve bool
var endpoint string
pflag.BoolVarP(&local, "local", "l", true, "run a local interactive REPL")
pflag.BoolVarP(&serve, "serve", "s", false, "run a networked multiuser server")
pflag.StringVarP(&endpoint, "endpoint", "e", ":4000", "where to run the networked server")
pflag.Parse()
done, events, spellbook := StartGame()
if serve {
go ListenTCP(endpoint, events, spellbook)
}
if local {
go ListenLocal(events, spellbook)
}
interrupt := make(chan os.Signal)
signal.Notify(interrupt, os.Interrupt)
quitting := false
for !quitting {
select {
case <-interrupt:
events <- &ShutdownEvent{}
case err := <-done:
log.Print("main() stopping: ", err)
quitting = true
}
}
}
示例3: init
func init() {
flag.Usage = printUsage
// set the defaults
defaultSSL = true
defaultPort = 38332
defaultAddress = "localhost"
defaultConfigPath := computeDefaultConfigPath()
flag.StringVarP(&flagConfigPath, "config", "c", defaultConfigPath, "config file path")
flag.StringVarP(&flagUsername, "rpcuser", "u", "", "rpc user name")
flag.StringVarP(&flagPassword, "rpcpassword", "p", "", "rpc password")
flag.BoolVar(&flagSSL, "ssl", defaultSSL, "use secure sockets SSL")
flag.IntVarP(&flagPort, "port", "n", defaultPort, "port number")
flag.StringVarP(&flagAddress, "host", "a", defaultAddress, "server address")
flag.BoolVarP(&verbose, "verbose", "v", false, "verbose output for debugging")
// k , ignore server certificate errors (not recommended, only for testing self-signed certificates")
flag.BoolVar(&flagHelp, "help", false, "Display this information")
flag.BoolVar(&flagVersion, "version", false, "Display version information")
flag.BoolVarP(&flagInsecure, "insecure", "k", false, "Allow connections to servers with 'insecure' SSL connections e.g. self-signed certificates. By default, this option is false, unless the server is localhost or an explicit IP address, in which case the option is true.")
flag.Parse()
flagSetMap = make(map[string]bool)
flag.Visit(visitFlagSetMap)
}
示例4: init
func init() {
flag.BoolVarP(&flagVerbose, "verbose", "v", false, "be more verbose")
flag.BoolVarP(&flagQuiet, "quiet", "q", false, "be quiet")
flag.BoolVarP(&flagTrace, "trace", "t", false, "trace bytes copied")
flag.StringVarP(&flagHost, "host", "h", "", "host to listen on")
flag.Uint16VarP(&flagPort, "port", "p", 8000, "port to listen on")
flag.VarP(&flagAllowedSourceIPs, "source-ips", "s",
"valid source IP addresses (if none given, all allowed)")
flag.VarP(&flagAllowedDestinationIPs, "dest-ips", "d",
"valid destination IP addresses (if none given, all allowed)")
flag.StringVar(&flagRemoteListener, "remote-listener", "",
"open the SOCKS port on the remote address (e.g. ssh://user:[email protected]:port)")
}
示例5: main
func main() {
var profile, version bool
flag.BoolVarP(&version, "version", "v", false, "\tShow version")
flag.BoolVar(&profile, "profile", false, "\tEnable profiler")
flag.Parse()
InitConfig()
Config.MaxResults = 20
if profile {
f, err := os.Create("alexandria.prof")
if err != nil {
panic(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
// TODO run GenerateIndex() when there is something new
if version {
fmt.Println(NAME, VERSION)
return
}
http.HandleFunc("/", mainHandler)
http.HandleFunc("/stats", statsHandler)
http.HandleFunc("/search", queryHandler)
http.HandleFunc("/alexandria.edit", editHandler)
serveDirectory("/images/", Config.CacheDirectory)
serveDirectory("/static/", Config.TemplateDirectory+"static")
http.ListenAndServe("127.0.0.1:41665", nil)
}
示例6: main
func main() {
var profile, version bool
flag.BoolVarP(&version, "version", "v", false, "\tShow version")
flag.BoolVar(&profile, "profile", false, "\tEnable profiler")
flag.Parse()
InitConfig()
if profile {
f, err := os.Create("alexandria.prof")
if err != nil {
panic(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
// TODO run when there is something new render.GenerateIndex()
if version {
fmt.Println(NAME, VERSION)
return
}
err := qml.Run(run)
if err != nil {
panic(err)
}
}
示例7: parseFlags
func parseFlags() (*cmdConfig, *busltee.Config, error) {
publisherConf := &busltee.Config{}
cmdConf := &cmdConfig{}
cmdConf.RollbarEnvironment = os.Getenv("ROLLBAR_ENVIRONMENT")
cmdConf.RollbarToken = os.Getenv("ROLLBAR_TOKEN")
// Connection related flags
flag.BoolVarP(&publisherConf.Insecure, "insecure", "k", false, "allows insecure SSL connections")
flag.IntVar(&publisherConf.Retry, "retry", 5, "max retries for connect timeout errors")
flag.IntVar(&publisherConf.StreamRetry, "stream-retry", 60, "max retries for streamer disconnections")
flag.Float64Var(&publisherConf.Timeout, "connect-timeout", 1, "max number of seconds to connect to busl URL")
// Logging related flags
flag.StringVar(&publisherConf.LogPrefix, "log-prefix", "", "log prefix")
flag.StringVar(&publisherConf.LogFile, "log-file", "", "log file")
flag.StringVar(&publisherConf.RequestID, "request-id", "", "request id")
if flag.Parse(); len(flag.Args()) < 2 {
return nil, nil, errors.New("insufficient args")
}
publisherConf.URL = flag.Arg(0)
publisherConf.Args = flag.Args()[1:]
return cmdConf, publisherConf, nil
}
示例8: init
func init() {
flag.BoolVarP(&flagVerbose, "verbose", "v", false, "be verbose")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: binscope [options] <file1>...\n")
flag.PrintDefaults()
}
}
示例9: parseArgs
func parseArgs() args {
result := args{}
pflag.Usage = usage
pflag.BoolVarP(&result.options.KeepGoing, "keep-going", "k", false, "")
pflag.BoolVar(&result.options.CheckAll, "check-all", false, "")
pflag.StringVarP(&result.scriptFile, "file", "f", "", "")
verbose := pflag.BoolP("verbose", "v", false, "")
quiet := pflag.BoolP("quiet", "q", false, "")
topics := pflag.String("debug", "", "")
pflag.Parse()
if *topics != "" {
result.debugTopics = strings.Split(*topics, ",")
}
// argh: really, we just want a callback for each occurence of -q
// or -v, which decrements or increments verbosity
if *quiet {
result.verbosity = 0
} else if *verbose {
result.verbosity = 2
} else {
result.verbosity = 1
}
result.options.Targets = pflag.Args()
return result
}
示例10: parseFlags
func (cm *ConfigManager) parseFlags() {
pflag.StringVarP(&cm.Flags.ConfigFile, "configfile", "c", DefaultConfigFile, "Path to config")
pflag.StringVarP(&cm.Flags.DestHost, "dest-host", "d", "", "Destination syslog hostname or IP")
pflag.IntVarP(&cm.Flags.DestPort, "dest-port", "p", 0, "Destination syslog port")
if utils.CanDaemonize {
pflag.BoolVarP(&cm.Flags.NoDaemonize, "no-detach", "D", false, "Don't daemonize and detach from the terminal")
} else {
cm.Flags.NoDaemonize = true
}
pflag.StringVarP(&cm.Flags.Facility, "facility", "f", "user", "Facility")
pflag.StringVar(&cm.Flags.Hostname, "hostname", "", "Local hostname to send from")
pflag.StringVar(&cm.Flags.PidFile, "pid-file", "", "Location of the PID file")
// --parse-syslog
pflag.StringVarP(&cm.Flags.Severity, "severity", "s", "notice", "Severity")
// --strip-color
pflag.BoolVar(&cm.Flags.UseTCP, "tcp", false, "Connect via TCP (no TLS)")
pflag.BoolVar(&cm.Flags.UseTLS, "tls", false, "Connect via TCP with TLS")
pflag.BoolVar(&cm.Flags.Poll, "poll", false, "Detect changes by polling instead of inotify")
pflag.Var(&cm.Flags.RefreshInterval, "new-file-check-interval", "How often to check for new files")
_ = pflag.Bool("no-eventmachine-tail", false, "No action, provided for backwards compatibility")
_ = pflag.Bool("eventmachine-tail", false, "No action, provided for backwards compatibility")
pflag.StringVar(&cm.Flags.DebugLogFile, "debug-log-cfg", "", "the debug log file")
pflag.StringVar(&cm.Flags.LogLevels, "log", "<root>=INFO", "\"logging configuration <root>=INFO;first=TRACE\"")
pflag.Parse()
cm.FlagFiles = pflag.Args()
}
示例11: main
func main() {
var index, profile, stats, version bool
flag.BoolVarP(&index, "index", "i", false, "\tUpdate the index")
flag.BoolVarP(&stats, "stats", "S", false, "\tPrint some statistics")
flag.BoolVarP(&version, "version", "v", false, "\tShow version")
flag.BoolVar(&profile, "profile", false, "\tEnable profiler")
flag.Parse()
InitConfig()
Config.MaxResults = 1e9
if profile {
f, err := os.Create("alexandria.prof")
if err != nil {
panic(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
switch {
case index:
GenerateIndex()
case stats:
printStats()
case version:
fmt.Println(NAME, VERSION)
default:
i := 1
if len(os.Args) > 0 {
if os.Args[1] == "--" {
i += 1
} else if os.Args[1] == "all" {
fmt.Printf("Rendered all %d scrolls.\n", RenderAllScrolls())
os.Exit(0)
}
}
results, err := FindScrolls(strings.Join(os.Args[i:], " "))
if err != nil {
panic(err)
}
fmt.Printf("There are %d matching scrolls.\n", len(results.Ids))
for _, id := range results.Ids {
fmt.Println("file://" + Config.CacheDirectory + string(id.Id) + ".png")
}
}
}
示例12: init
func init() {
flag.StringVarP(&flagPlatform, "platform", "p", "linux",
"the platform to build for")
flag.StringVarP(&flagArch, "arch", "a", "amd64",
"the architecture to build for")
flag.StringVar(&flagBuildDir, "build-dir", "/tmp/sbuild",
"the directory to use as a build directory")
flag.BoolVarP(&flagVerbose, "verbose", "v", false, "be verbose")
}
示例13: Run
func (mmsd *mmsdService) Run() {
flag.BoolVarP(&mmsd.Verbose, "verbose", "v", mmsd.Verbose, "Set verbosity level")
flag.IPVar(&mmsd.MarathonIP, "marathon-ip", mmsd.MarathonIP, "Marathon endpoint TCP IP address")
flag.UintVar(&mmsd.MarathonPort, "marathon-port", mmsd.MarathonPort, "Marathon endpoint TCP port number")
flag.DurationVar(&mmsd.ReconnectDelay, "reconnect-delay", mmsd.ReconnectDelay, "Marathon reconnect delay")
flag.StringVar(&mmsd.RunStateDir, "run-state-dir", mmsd.RunStateDir, "Path to directory to keep run-state")
flag.StringVar(&mmsd.FilterGroups, "filter-groups", mmsd.FilterGroups, "Application group filter")
flag.IPVar(&mmsd.ManagedIP, "managed-ip", mmsd.ManagedIP, "IP-address to manage for mmsd")
flag.BoolVar(&mmsd.GatewayEnabled, "enable-gateway", mmsd.GatewayEnabled, "Enables gateway support")
flag.IPVar(&mmsd.GatewayAddr, "gateway-bind", mmsd.GatewayAddr, "gateway bind address")
flag.UintVar(&mmsd.GatewayPortHTTP, "gateway-port-http", mmsd.GatewayPortHTTP, "gateway port for HTTP")
flag.UintVar(&mmsd.GatewayPortHTTPS, "gateway-port-https", mmsd.GatewayPortHTTPS, "gateway port for HTTPS")
flag.BoolVar(&mmsd.FilesEnabled, "enable-files", mmsd.FilesEnabled, "enables file based service discovery")
flag.BoolVar(&mmsd.UDPEnabled, "enable-udp", mmsd.UDPEnabled, "enables UDP load balancing")
flag.BoolVar(&mmsd.TCPEnabled, "enable-tcp", mmsd.TCPEnabled, "enables haproxy TCP load balancing")
flag.BoolVar(&mmsd.LocalHealthChecks, "enable-health-checks", mmsd.LocalHealthChecks, "Enable local health checks (if available) instead of relying on Marathon health checks alone.")
flag.StringVar(&mmsd.HaproxyBin, "haproxy-bin", mmsd.HaproxyBin, "path to haproxy binary")
flag.StringVar(&mmsd.HaproxyTailCfg, "haproxy-cfgtail", mmsd.HaproxyTailCfg, "path to haproxy tail config file")
flag.IPVar(&mmsd.ServiceAddr, "haproxy-bind", mmsd.ServiceAddr, "haproxy management port")
flag.UintVar(&mmsd.HaproxyPort, "haproxy-port", mmsd.HaproxyPort, "haproxy management port")
flag.BoolVar(&mmsd.DnsEnabled, "enable-dns", mmsd.DnsEnabled, "Enables DNS-based service discovery")
flag.UintVar(&mmsd.DnsPort, "dns-port", mmsd.DnsPort, "DNS service discovery port")
flag.BoolVar(&mmsd.DnsPushSRV, "dns-push-srv", mmsd.DnsPushSRV, "DNS service discovery to also push SRV on A")
flag.StringVar(&mmsd.DnsBaseName, "dns-basename", mmsd.DnsBaseName, "DNS service discovery's base name")
flag.DurationVar(&mmsd.DnsTTL, "dns-ttl", mmsd.DnsTTL, "DNS service discovery's reply message TTL")
showVersionAndExit := flag.BoolP("version", "V", false, "Shows version and exits")
flag.Usage = func() {
showVersion()
fmt.Fprintf(os.Stderr, "\nUsage: mmsd [flags ...]\n\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\n")
}
flag.Parse()
if *showVersionAndExit {
showVersion()
os.Exit(0)
}
mmsd.setupHandlers()
mmsd.setupEventBusListener()
mmsd.setupHttpService()
<-mmsd.quitChannel
}
示例14: setup
// Initial setup when the program starts.
func setup() {
// ensure that zpool/zfs commands do not use localized messages:
os.Setenv("LC_ALL", "C")
// command line flags:
pflag.StringVarP(&cfgFile, "conf", "c", CFGFILE, "configuration file path")
pflag.BoolVarP(&optDebug, "debug", "d", false, "print debug information to stdout")
optHashPassword := pflag.BoolP("passwordhash", "P", false, "hash web password")
optTest := pflag.BoolP("test", "t", false, "test configuration and exit")
optVersion := pflag.BoolP("version", "v", false, "print version information and exit")
pflag.Parse()
if pflag.NArg() > 0 {
pflag.Usage()
os.Exit(2)
}
if *optVersion {
version()
os.Exit(0)
}
if *optHashPassword {
wwwHashPassword()
os.Exit(0)
}
// initialize logging & notification:
if *optTest {
optDebug = true
}
cfg = getCfg()
if cfg == nil {
os.Exit(2)
}
notify = setupLog(cfg)
if *optTest {
notifyCloseC := notify.Close()
select { // wait max 1 second for loggers to finish
case <-notifyCloseC:
case <-time.After(time.Second):
}
os.Exit(0)
}
}
示例15: main
func main() {
var err error
var cp string
var initial bool
var conferr error
flag.StringVarP(&cp, "conf", "c", "conf.yml", "Local path to configuration file.")
flag.BoolVarP(&initial, "initial", "i", false, "Run the initial setup of the server.")
flag.Parse()
conferr = conf.Load(cp)
if conferr != nil || initial {
setup.Run()
}
if err = utils.EnsureDir(conf.C.UploadDir); err != nil {
log.Fatal(err)
}
if db, err = gorm.Open("sqlite3", conf.C.DB); err != nil {
log.Fatal(err)
}
db.AutoMigrate(&models.ResourceEntry{})
go monitoring.Monit(&db)
log.Printf("[INFO][System]\tStarted goploader server on port %d\n", conf.C.Port)
if !conf.C.Debug {
gin.SetMode(gin.ReleaseMode)
}
// Default router
r := gin.Default()
// Templates and static files
r.LoadHTMLGlob("templates/*")
r.Static("/static", "./assets")
r.Static("/favicon.ico", "./assets/favicon.ico")
// Routes
r.GET("/", index)
r.POST("/", create)
r.GET("/v/:uniuri/:key", view)
// Run
r.Run(fmt.Sprintf(":%d", conf.C.Port))
}