| // Copyright 2021 The Fuchsia Authors. All rights reserved. |
| // 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 |
| authFlags authcli.Flags |
| project string |
| |
| parsedAuthOpts auth.Options |
| } |
| |
| func (c *commonFlags) Init(authOpts auth.Options) { |
| c.authFlags = authcli.Flags{} |
| c.authFlags.Register(&c.Flags, authOpts) |
| c.Flags.StringVar(&c.project, "project", "", "Name of Google Cloud project.") |
| } |
| |
| func (c *commonFlags) Parse() error { |
| var err error |
| c.parsedAuthOpts, err = c.authFlags.Options() |
| if err != nil { |
| return err |
| } |
| if c.project == "" { |
| return fmt.Errorf("-project is required") |
| } |
| return nil |
| } |