go.fuchsia.dev/infra@v0.0.0-20240507153436-9b593402251b/cmd/ftxtest/common.go (about)

     1  // Copyright 2023 The Fuchsia Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style license that can be
     3  // found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"github.com/maruel/subcommands"
     9  
    10  	"go.chromium.org/luci/auth"
    11  	"go.chromium.org/luci/auth/client/authcli"
    12  )
    13  
    14  type commonFlags struct {
    15  	subcommands.CommandRunBase
    16  	authFlags authcli.Flags
    17  	project   string
    18  
    19  	parsedAuthOpts auth.Options
    20  }
    21  
    22  func (c *commonFlags) Init(authOpts auth.Options) {
    23  	c.authFlags = authcli.Flags{}
    24  	c.authFlags.Register(&c.Flags, authOpts)
    25  }
    26  
    27  func (c *commonFlags) Parse() error {
    28  	var err error
    29  	c.parsedAuthOpts, err = c.authFlags.Options()
    30  	if err != nil {
    31  		return err
    32  	}
    33  	return nil
    34  }