go.fuchsia.dev/infra@v0.0.0-20240507153436-9b593402251b/cmd/gcs-util/main.go (about)

     1  // Copyright 2022 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  	"log"
     9  	"os"
    10  
    11  	"github.com/maruel/subcommands"
    12  	"go.chromium.org/luci/auth"
    13  	"go.chromium.org/luci/auth/client/authcli"
    14  	"go.chromium.org/luci/client/versioncli"
    15  	"go.chromium.org/luci/hardcoded/chromeinfra"
    16  )
    17  
    18  const (
    19  	// Version must be updated on functional change (behavior, arguments, supported commands).
    20  	version = "0.0.1"
    21  )
    22  
    23  func getApplication(defaultAuthOpts auth.Options) *subcommands.DefaultApplication {
    24  	defaultAuthOpts.Scopes = []string{
    25  		"https://www.googleapis.com/auth/devstorage.read_write",
    26  		"https://www.googleapis.com/auth/userinfo.email",
    27  	}
    28  	return &subcommands.DefaultApplication{
    29  		Name:  "gcs-util",
    30  		Title: "Client for interacting with GCS.",
    31  		Commands: []*subcommands.Command{
    32  			cmdUp(defaultAuthOpts),
    33  			cmdVerifyBlobs(),
    34  			authcli.SubcommandInfo(defaultAuthOpts, "whoami", false),
    35  			authcli.SubcommandLogin(defaultAuthOpts, "login", false),
    36  			authcli.SubcommandLogout(defaultAuthOpts, "logout", false),
    37  			versioncli.CmdVersion(version),
    38  			subcommands.CmdHelp,
    39  		},
    40  	}
    41  }
    42  
    43  func main() {
    44  	log.SetFlags(log.Lmicroseconds)
    45  	app := getApplication(chromeinfra.DefaultAuthOptions())
    46  	os.Exit(subcommands.Run(app, nil))
    47  }