blob: 846db13cea511d41c7f0aa9d2a27cc5bd446c398 [file] [log] [blame]
// Copyright 2021 The Fuchsia Authors.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package main
import (
"fmt"
"github.com/maruel/subcommands"
"go.chromium.org/luci/auth"
"go.chromium.org/luci/auth/client/authcli"
)
type commonFlags struct {
subcommands.CommandRunBase
bbHost string
authFlags authcli.Flags
parsedAuthOpts auth.Options
}
func (c *commonFlags) Init(authOpts auth.Options) {
c.authFlags = authcli.Flags{}
c.authFlags.Register(&c.Flags, authOpts)
c.Flags.StringVar(&c.bbHost, "bb-host", "cr-buildbucket.appspot.com", "Buildbucket host to use.")
}
func (c *commonFlags) Parse() error {
var err error
c.parsedAuthOpts, err = c.authFlags.Options()
if err != nil {
return err
}
if c.bbHost == "" {
return fmt.Errorf("-bb-host is required")
}
return nil
}