gh auth login · cli/cli@35f18b6 · GitHub
Skip to content

Commit 35f18b6

Browse files
committed
gh auth login
1 parent b4ffced commit 35f18b6

13 files changed

Lines changed: 896 additions & 38 deletions

File tree

‎api/client.go‎

Lines changed: 28 additions & 18 deletions

‎command/root.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"github.com/cli/cli/internal/ghrepo"
2323
"github.com/cli/cli/internal/run"
2424
apiCmd "github.com/cli/cli/pkg/cmd/api"
25+
authCmd "github.com/cli/cli/pkg/cmd/auth"
26+
authLoginCmd "github.com/cli/cli/pkg/cmd/auth/login"
2527
gistCreateCmd "github.com/cli/cli/pkg/cmd/gist/create"
2628
prCheckoutCmd "github.com/cli/cli/pkg/cmd/pr/checkout"
2729
prDiffCmd "github.com/cli/cli/pkg/cmd/pr/diff"
@@ -134,6 +136,9 @@ func init() {
134136
RootCmd.AddCommand(gistCmd)
135137
gistCmd.AddCommand(gistCreateCmd.NewCmdCreate(cmdFactory, nil))
136138

139+
RootCmd.AddCommand(authCmd.Cmd)
140+
authCmd.Cmd.AddCommand(authLoginCmd.NewCmdLogin(cmdFactory, nil))
141+
137142
resolvedBaseRepo := func() (ghrepo.Interface, error) {
138143
httpClient, err := cmdFactory.HttpClient()
139144
if err != nil {

‎internal/config/config_setup.go‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/cli/cli/api"
1111
"github.com/cli/cli/auth"
12+
"github.com/cli/cli/utils"
1213
)
1314

1415
var (
@@ -67,7 +68,7 @@ func authFlow(oauthHost, notice string) (string, string, error) {
6768
}
6869

6970
fmt.Fprintln(os.Stderr, notice)
70-
fmt.Fprintf(os.Stderr, "Press Enter to open %s in your browser... ", flow.Hostname)
71+
fmt.Fprintf(os.Stderr, "- %s to open %s in your browser... ", utils.Bold("Press Enter"), flow.Hostname)
7172
_ = waitForEnter(os.Stdin)
7273
token, err := flow.ObtainAccessToken()
7374
if err != nil {
@@ -83,7 +84,8 @@ func authFlow(oauthHost, notice string) (string, string, error) {
8384
}
8485

8586
func AuthFlowComplete() {
86-
fmt.Fprintln(os.Stderr, "Authentication complete. Press Enter to continue... ")
87+
fmt.Fprintf(os.Stderr, "%s Authentication complete. %s to continue...\n",
88+
utils.GreenCheck(), utils.Bold("Press Enter"))
8789
_ = waitForEnter(os.Stdin)
8890
}
8991

‎pkg/cmd/auth/auth.go‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package auth
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
var Cmd = &cobra.Command{
8+
Use: "auth <command>",
9+
Short: "Login, logout, and refresh your authentication",
10+
Long: `Manage gh's authentication state.`,
11+
// TODO this all doesn't exist yet
12+
//Example: heredoc.Doc(`
13+
// $ gh auth login
14+
// $ gh auth status
15+
// $ gh auth refresh --scopes gist
16+
// $ gh auth logout
17+
//`),
18+
}

‎pkg/cmd/auth/login/client.go‎

Lines changed: 48 additions & 0 deletions

0 commit comments

Comments
 (0)