X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/380a54a7d97b34119cbaa3bee05d6b6cd241eee5..8b873a9b3b8865a4d451263e48b49122b9c32759:/lib/service/cmd.go diff --git a/lib/service/cmd.go b/lib/service/cmd.go index 603f48890e..b6737bc553 100644 --- a/lib/service/cmd.go +++ b/lib/service/cmd.go @@ -10,7 +10,6 @@ import ( "flag" "fmt" "io" - "io/ioutil" "net" "net/http" "net/url" @@ -62,20 +61,25 @@ func (c *command) RunCommand(prog string, args []string, stdin io.Reader, stdout log.WithError(err).Info("exiting") } }() + flags := flag.NewFlagSet("", flag.ContinueOnError) flags.SetOutput(stderr) - configFile := flags.String("config", arvados.DefaultConfigFile, "Site configuration `file`") + + loader := config.NewLoader(stdin, log) + loader.SetupFlags(flags) + versionFlag := flags.Bool("version", false, "Write version information to stdout and exit 0") + err = flags.Parse(args) if err == flag.ErrHelp { err = nil return 0 } else if err != nil { return 2 + } else if *versionFlag { + return cmd.Version.RunCommand(prog, args, stdin, stdout, stderr) } - // Logged warnings are discarded for now: the config template - // is incomplete, which causes extra warnings about keys that - // are really OK. - cfg, err := config.LoadFile(*configFile, ctxlog.New(ioutil.Discard, "json", "error")) + + cfg, err := loader.Load() if err != nil { return 1 }