go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/auth/client/luci_auth/luci_auth.go (about) 1 // Copyright 2017 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package luci_auth 16 17 import ( 18 "context" 19 20 "github.com/maruel/subcommands" 21 22 "go.chromium.org/luci/auth" 23 "go.chromium.org/luci/auth/client/authcli" 24 "go.chromium.org/luci/client/versioncli" 25 "go.chromium.org/luci/common/cli" 26 "go.chromium.org/luci/common/logging/gologger" 27 ) 28 29 // Version is the version of luci-auth tool. 30 const Version = "1.3.2" 31 32 // GetApplication returns cli.Application that implements 'luci-auth'. 33 // 34 // It does NOT hardcode any default values. Defaults are hardcoded in 35 // corresponding 'main' package. 36 func GetApplication(defaultAuthOpts auth.Options) *cli.Application { 37 return &cli.Application{ 38 Name: "luci-auth", 39 Title: "LUCI Authentication Utility (luci-auth v" + Version + ")", 40 41 Context: func(ctx context.Context) context.Context { 42 return gologger.StdConfig.Use(ctx) 43 }, 44 45 Commands: []*subcommands.Command{ 46 subcommands.CmdHelp, 47 versioncli.CmdVersion("luci-auth v" + Version), 48 49 authcli.SubcommandLoginWithParams(authcli.CommandParams{ 50 Name: "login", 51 AuthOptions: defaultAuthOpts, 52 UseScopeFlags: true, 53 }), 54 authcli.SubcommandLogoutWithParams(authcli.CommandParams{ 55 Name: "logout", 56 AuthOptions: defaultAuthOpts, 57 UseScopeFlags: true, 58 }), 59 60 authcli.SubcommandInfoWithParams(authcli.CommandParams{ 61 Name: "info", 62 AuthOptions: defaultAuthOpts, 63 UseScopeFlags: true, 64 UseIDTokenFlags: true, 65 }), 66 authcli.SubcommandTokenWithParams(authcli.CommandParams{ 67 Name: "token", 68 AuthOptions: defaultAuthOpts, 69 UseScopeFlags: true, 70 UseIDTokenFlags: true, 71 }), 72 73 authcli.SubcommandContextWithParams(authcli.CommandParams{ 74 Name: "context", 75 AuthOptions: defaultAuthOpts, 76 UseScopeFlags: true, 77 }), 78 }, 79 } 80 }