MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / ParseCommandLine

Function ParseCommandLine

rest/config_legacy.go:512–660  ·  view source on GitHub ↗

Reads the command line flags and the optional config file.

(ctx context.Context, args []string, handling flag.ErrorHandling)

Source from the content-addressed store, hash-verified

510
511// Reads the command line flags and the optional config file.
512func ParseCommandLine(ctx context.Context, args []string, handling flag.ErrorHandling) (*LegacyServerConfig, error) {
513 flagSet := flag.NewFlagSet(args[0], handling)
514
515 _ = flagSet.Bool("disable_persistent_config", false, "")
516
517 _ = flagSet.Bool("api.admin_interface_authentication", true, "")
518 _ = flagSet.Bool("api.metrics_interface_authentication", true, "")
519 _ = flagSet.Bool("bootstrap.use_tls_server", true, "")
520 _ = flagSet.Bool("unsupported.user_queries", true, "")
521
522 addr := flagSet.String("interface", DefaultPublicInterface, "Address to bind to")
523 authAddr := flagSet.String("adminInterface", DefaultAdminInterface, "Address to bind admin interface to")
524 profAddr := flagSet.String("profileInterface", "", "Address to bind profile interface to")
525 configServer := flagSet.String("configServer", "", "URL of server that can return database configs")
526 deploymentID := flagSet.String("deploymentID", "", "Customer/project identifier for stats reporting")
527 couchbaseURL := flagSet.String("url", "", "Address of Couchbase server")
528 dbName := flagSet.String("dbname", "", "Name of Couchbase Server database (defaults to name of bucket)")
529 pretty := flagSet.Bool("pretty", false, "Pretty-print JSON responses")
530 verbose := flagSet.Bool("verbose", false, "Log more info about requests")
531 logKeys := flagSet.String("log", "", "Log keys, comma separated")
532 logFilePath := flagSet.String("logFilePath", "", "Path to log files")
533 certpath := flagSet.String("certpath", "", "Client certificate path")
534 cacertpath := flagSet.String("cacertpath", "", "Root CA certificate path")
535 keypath := flagSet.String("keypath", "", "Client certificate key path")
536
537 // used by service scripts as a way to specify a per-distro defaultLogFilePath
538 flagSet.String("defaultLogFilePath", "", "Path to log files, if not overridden by --logFilePath, or the config")
539
540 _ = flagSet.Parse(args[1:])
541 var config *LegacyServerConfig
542 var err error
543
544 if flagSet.NArg() > 0 {
545 // Read the configuration file(s), if any:
546 for _, filename := range flagSet.Args() {
547 newConfig, newConfigErr := LoadLegacyServerConfig(ctx, filename)
548
549 if newConfigErr != nil {
550 return config, pkgerrors.WithMessage(newConfigErr, fmt.Sprintf("Error reading config file %s", filename))
551 }
552
553 if config == nil {
554 config = newConfig
555 } else {
556 if err := config.MergeWith(newConfig); err != nil {
557 return config, pkgerrors.WithMessage(err, fmt.Sprintf("Error reading config file %s", filename))
558 }
559 }
560 }
561
562 // Override the config file with global settings from command line flags:
563 if *addr != DefaultPublicInterface {
564 config.Interface = addr
565 }
566 if *authAddr != DefaultAdminInterface {
567 config.AdminInterface = authAddr
568 }
569 if *profAddr != "" {

Calls 6

MergeWithMethod · 0.95
PtrFunction · 0.92
SetFromArrayFunction · 0.92
LoadLegacyServerConfigFunction · 0.85
ArgsMethod · 0.80
StringMethod · 0.65