本文整理匯總了Golang中github.com/ogier/pflag.PrintDefaults函數的典型用法代碼示例。如果您正苦於以下問題:Golang PrintDefaults函數的具體用法?Golang PrintDefaults怎麽用?Golang PrintDefaults使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了PrintDefaults函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: printHelp
// Print usage information about the frosty backup tool.
func printHelp() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
fmt.Fprintf(os.Stderr, "\n\tfrosty <path-to-frosty-config-file> [flags...]\n\n")
fmt.Fprintf(os.Stderr, "Flags:\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\n%s\n", frostyVersion)
}
示例2: init
func init() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "%s [configFile]\n", os.Args[0])
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\n%s", copyright())
}
}
示例3: main
func main() {
var config Config
flag.BoolVar(&DEBUG, "debug", false, "enable debug logging")
flag.BoolVar(&QUIET, "quiet", false, "disable output")
flag.StringVar(&config.FieldSep, "csv-fields-terminated-by", "\t", "field separator")
flag.StringVar(&config.RowSep, "csv-records-terminated-by", "\n", "row separator")
flag.StringVar(&config.NullString, "csv-null-string", "\\N", "output string for NULL values")
flag.BoolVar(&config.DateEpoch, "epoch", true, "output datetime as epoch instead of RFC3339")
defaults_file := flag.String("defaults-file", "my.cnf", "defaults file")
defaults_group_suffix := flag.String("defaults-group-suffix", "", "defaults group suffix")
format := flag.String("format", "json", "output format 'json' or 'csv'")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: mysqlcsvdump [options] database table > output.json\n\n")
fmt.Fprintf(os.Stderr, "Reads connection info from ./my.cnf. Use '-' for table to send query in stdin\n\n")
flag.PrintDefaults()
}
flag.Parse()
args := flag.Args()
if len(args) < 2 {
flag.Usage()
os.Exit(1)
}
dsn := getDSN(*defaults_file, "client"+*defaults_group_suffix, args[0])
rows := getRows(dsn, args[1])
if *format == "json" {
NewJsonWriter(&config).WriteRows(rows)
} else {
NewCsvWriter(&config).WriteRows(rows)
}
}
示例4: usageLong
func usageLong() {
// NOTE: the help message uses spaces, not tabs for indentation!
errf(`boot2docker management utility.
Usage: %s [<options>] <command> [<args>]
Commands:
init [<vm>] Create a new boot2docker VM.
up|start|boot [<vm>] Start VM from any states.
ssh Login to VM via SSH.
save|suspend [<vm>] Suspend VM and save state to disk.
down|stop|halt [<vm>] Gracefully shutdown the VM.
restart [<vm>] Gracefully reboot the VM.
poweroff [<vm>] Forcefully power off the VM (might corrupt disk image).
reset [<vm>] Forcefully power cycle the VM (might corrupt disk image).
delete [<vm>] Delete boot2docker VM and its disk image.
info [<vm>] Display detailed information of VM.
status [<vm>] Display current state of VM.
download Download boot2docker ISO image.
version Display version information.
Options:
`, os.Args[0])
flag.PrintDefaults()
}
示例5: main
func main() {
pflag.Usage = func() {
fmt.Printf(`usage: tuplespaced [flags]
Run tuplespace server.
Flags:
`)
pflag.PrintDefaults()
}
pflag.Parse()
runtime.GOMAXPROCS(*ncpuFlag)
log.AddFilter("stdout", logLevels[*logLevelFlag], log.NewConsoleLogWriter())
debug := logLevels[*logLevelFlag] <= log.DEBUG
log.Info("Starting server on http://%s/tuplespace/", *bindFlag)
ts := tuplespace.NewTupleSpace(store.NewMemoryStore())
srv := &http.Server{
Addr: *bindFlag,
Handler: makeService(ts, debug),
ReadTimeout: *readTimeoutFlag,
WriteTimeout: *writeTimeoutFlag,
}
err := srv.ListenAndServe()
if err != nil {
fatalf("error: %s\n", err)
}
}
示例6: 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()
}
}
示例7: main
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "fsping: check responsiveness of mounted filesystems\n\n")
flag.PrintDefaults()
}
flag.Parse()
fsnum := 0
fsch := make(chan fs_t)
fsmap := readmounts()
args := flag.Args()
// if extra args were specified keep only filesystems listed
if len(args) > 0 {
L:
for fs, _ := range fsmap {
for _, a := range args {
if fs == a {
continue L
}
}
delete(fsmap, fs)
}
}
// fire them up
for _, fs := range fsmap {
fsnum += 1
// fire off a goroutine for each mounted nfs
// filesystem. fsch is used for completion
// notifications
go statit(fs, fsch)
}
// timeout ticker
tick := time.Tick(*timeout)
// collect results
for fsnum > 0 {
select {
case fs := <-fsch:
if *verbose || fs.err != nil {
fmt.Println(fs)
}
fsmap[fs.path] = fs
fsnum -= 1
case <-tick:
// ticker has kicked in, print timeout
// messages for filesystems that haven't
// finished
for _, fs := range fsmap {
if !*quiet && !fs.done {
fmt.Println(fs)
}
}
os.Exit(1)
}
}
}
示例8: main
func main() {
pflag.Parse()
if helpFlag {
pflag.PrintDefaults()
return
}
if versionFlag {
log.Printf("This is version %d.%d-%d.", MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
return
}
log.Printf("Starting up version %d.%d-%d...\n", MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
// Read configuration
_, err := os.Open(workerDirFlag)
if err != nil {
if err == os.ErrNotExist || err == os.ErrInvalid {
err = os.Mkdir(workerDirFlag, os.ModeDir)
if err != nil {
log.Panicf("Could not create worker dir: %s", err)
}
} else {
log.Panicf("Error accessing worker directory: %s", err)
}
}
log.Printf("Reading worker configuration:\n")
fileWalkErr := filepath.Walk(workerDirFlag, visit)
if fileWalkErr != nil {
log.Panicf("There seems to have been a problem reading configuration: %s\n", fileWalkErr)
}
log.Printf("Starting up scheduler...\n")
r.Scheduler_Run()
if r.SchedulerStatus == 0 {
log.Panicf("Scheduler failed to start!\n")
}
log.Printf("Ping and Queue up Workers...\n")
// Establish Ping GoRoutine and add them to Scheduler
// (Should this just be connecting the workers? This way we set them as
// connected and have reservoir ping constantly until we disconnect.)
log.Printf("Start the API interface...\n")
// Start the API web interface here (goweb)?
log.Printf("Now active.\n")
mainBlock := make(chan bool)
<-mainBlock // Won't happen, just used to wait the main thread b/c we need to keep the prog active.
}
示例9: main
func main() {
var pathStrings pathSlice
filePtr := flag.StringP("file", "f", "", "Path to json file")
jsonPtr := flag.StringP("json", "j", "", "JSON text")
flag.VarP(&pathStrings, "path", "p", "One or more paths to target in JSON")
showKeysPtr := flag.BoolP("keys", "k", false, "Print keys & indexes that lead to value")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
flag.PrintDefaults()
fmt.Fprintln(os.Stderr, "Pipe JSON to StdIn by not specifying --file or --json ")
}
flag.Parse()
if len(pathStrings) == 0 {
fmt.Println("Must specify one or more paths with the --path flag")
os.Exit(1)
}
paths, err := jsonpath.ParsePaths(pathStrings...)
if err != nil {
fmt.Println(fmt.Errorf("Failed to parse paths: %q", err.Error()))
os.Exit(1)
}
if filePtr != nil && *filePtr != "" {
f, err := os.Open(*filePtr)
if err != nil {
fmt.Println(fmt.Errorf("Failed to open file: %q", err.Error()))
os.Exit(1)
}
eval, err := jsonpath.EvalPathsInReader(f, paths)
checkAndHandleError(err)
run(eval, *showKeysPtr)
checkAndHandleError(eval.Error)
f.Close()
} else if jsonPtr != nil && *jsonPtr != "" {
eval, err := jsonpath.EvalPathsInBytes([]byte(*jsonPtr), paths)
checkAndHandleError(err)
run(eval, *showKeysPtr)
checkAndHandleError(eval.Error)
} else {
reader := bufio.NewReader(os.Stdin)
eval, err := jsonpath.EvalPathsInReader(reader, paths)
checkAndHandleError(err)
run(eval, *showKeysPtr)
checkAndHandleError(eval.Error)
}
}
示例10: helpCmd
func helpCmd() {
usage := `Usage: remotectl <flags> <query> [--] <cmd>
Available Providers:
%s
Environment Vars:
`
fmt.Printf(usage, providers.Providers())
env.PrintDefaults(os.Stderr)
fmt.Println("\nFlags:")
flag.PrintDefaults()
}
示例11: init
func init() {
flag.Usage = func() {
fmt.Fprintf(
os.Stderr,
`Usage:
%s log_directory [options]
or
%s log_directory domains_file --generate [options]
with options:
`,
os.Args[0],
os.Args[0],
)
flag.PrintDefaults()
}
}
示例12: 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
}
示例13: init
func init() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: dockdash [options]\n\n")
flag.PrintDefaults()
}
flag.Parse()
if *helpFlag {
flag.Usage()
os.Exit(1)
}
if *versionFlag {
fmt.Println(VERSION)
os.Exit(0)
}
}
示例14: printUsage
func printUsage() {
_, file := path.Split(os.Args[0])
fmt.Printf("Usage: %s [options] command [params...]\n\n", file)
fmt.Printf("Options:\n")
flag.PrintDefaults()
fmt.Printf(`
Available JSON-RPC commands:
getstatus, stop
listwallets, createwallet, deletewallet
listbalances, listtransactions
listaddresses, createaddresses, setaddresslabel
addasset, setassetvisible, refreshasset, deleteasset
sendbitcoin, sendasset, sendbitcoinasset
sendbitcoinmessage, sendassetmessage, sendbitcoinassetmessage
listunspent, sendbitcoinusing, sendassetusing
`)
}
示例15: Tool
func Tool(desc string, outputter func(s *Stats)) {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [OPTION]... [FILE]...\n", os.Args[0])
fmt.Fprintf(os.Stderr, "%s\n\n", desc)
flag.PrintDefaults()
fmt.Fprintln(os.Stderr, "\nWith no FILE, or when FILE is -, read standard input.")
}
flag.Parse()
if *version {
fmt.Printf("%s %s\n", os.Args[0], programVersion)
return
}
s := NewStats()
calculate(s)
outputter(s)
}