go.fuchsia.dev/infra@v0.0.0-20240507153436-9b593402251b/cmd/cl-util/main.go (about) 1 // Copyright 2020 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 13 "go.chromium.org/luci/auth" 14 "go.chromium.org/luci/auth/client/authcli" 15 "go.chromium.org/luci/client/versioncli" 16 "go.chromium.org/luci/common/api/gerrit" 17 "go.chromium.org/luci/common/api/gitiles" 18 "go.chromium.org/luci/hardcoded/chromeinfra" 19 ) 20 21 // Version must be updated on functional change (behavior, arguments, supported commands). 22 const version = "0.0.7" 23 24 func getApplication(defaultAuthOpts auth.Options) *subcommands.DefaultApplication { 25 defaultAuthOpts.Scopes = []string{auth.OAuthScopeEmail, gitiles.OAuthScope, gerrit.OAuthScope} 26 return &subcommands.DefaultApplication{ 27 Name: "cl-util", 28 Title: "Client for manipulating gerrit CLs.", 29 Commands: []*subcommands.Command{ 30 cmdCreateCL(defaultAuthOpts), 31 cmdTriggerCQ(defaultAuthOpts), 32 cmdRunPostsubmitTryjobs(defaultAuthOpts), 33 cmdWaitForCQ(defaultAuthOpts), 34 cmdAbandonCL(defaultAuthOpts), 35 authcli.SubcommandInfo(defaultAuthOpts, "whoami", false), 36 authcli.SubcommandLogin(defaultAuthOpts, "login", false), 37 authcli.SubcommandLogout(defaultAuthOpts, "logout", false), 38 versioncli.CmdVersion(version), 39 subcommands.CmdHelp, 40 }, 41 } 42 } 43 44 func main() { 45 log.SetFlags(log.Lmicroseconds) 46 app := getApplication(chromeinfra.DefaultAuthOptions()) 47 os.Exit(subcommands.Run(app, nil)) 48 }