go.fuchsia.dev/infra@v0.0.0-20240507153436-9b593402251b/cmd/bigquery/main.go (about) 1 // Copyright 2021 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/bigquery", 26 "https://www.googleapis.com/auth/userinfo.email", 27 } 28 return &subcommands.DefaultApplication{ 29 Name: "bigquery", 30 Title: "Client for interacting with BigQuery.", 31 Commands: []*subcommands.Command{ 32 cmdQuery(defaultAuthOpts), 33 authcli.SubcommandInfo(defaultAuthOpts, "whoami", false), 34 authcli.SubcommandLogin(defaultAuthOpts, "login", false), 35 authcli.SubcommandLogout(defaultAuthOpts, "logout", false), 36 versioncli.CmdVersion(version), 37 subcommands.CmdHelp, 38 }, 39 } 40 } 41 42 func main() { 43 log.SetFlags(log.Lmicroseconds) 44 app := getApplication(chromeinfra.DefaultAuthOptions()) 45 os.Exit(subcommands.Run(app, nil)) 46 }