@@ -27,10 +27,11 @@ type LoginOptions struct {
2727
2828 Interactive bool
2929
30- Hostname string
31- Scopes []string
32- Token string
33- Web bool
30+ Hostname string
31+ Scopes []string
32+ Token string
33+ Web bool
34+ GitProtocol string
3435}
3536
3637func NewCmdLogin (f * cmdutil.Factory , runF func (* LoginOptions ) error ) * cobra.Command {
@@ -54,8 +55,8 @@ func NewCmdLogin(f *cmdutil.Factory, runF func(*LoginOptions) error) *cobra.Comm
5455 Alternatively, pass in a token on standard input by using %[1]s--with-token%[1]s.
5556 The minimum required scopes for the token are: "repo", "read:org".
5657
57- The --scopes flag accepts a comma separated list of scopes you want your gh credentials to have. If
58- absent, this command ensures that gh has access to a minimum set of scopes.
58+ The %[1]s --scopes%[1]s flag accepts a comma separated list of scopes you want your gh credentials to
59+ have. If absent, this command ensures that gh has access to a minimum set of scopes.
5960 ` , "`" ),
6061 Example : heredoc .Doc (`
6162 # start interactive setup
@@ -64,7 +65,7 @@ func NewCmdLogin(f *cmdutil.Factory, runF func(*LoginOptions) error) *cobra.Comm
6465 # authenticate against github.com by reading the token from a file
6566 $ gh auth login --with-token < mytoken.txt
6667
67- # authenticate with a specific GitHub Enterprise Server instance
68+ # authenticate with a specific GitHub instance
6869 $ gh auth login --hostname enterprise.internal
6970 ` ),
7071 RunE : func (cmd * cobra.Command , args []string ) error {
@@ -111,6 +112,7 @@ func NewCmdLogin(f *cmdutil.Factory, runF func(*LoginOptions) error) *cobra.Comm
111112 cmd .Flags ().StringSliceVarP (& opts .Scopes , "scopes" , "s" , nil , "Additional authentication scopes for gh to have" )
112113 cmd .Flags ().BoolVar (& tokenStdin , "with-token" , false , "Read token from standard input" )
113114 cmd .Flags ().BoolVarP (& opts .Web , "web" , "w" , false , "Open a browser to authenticate" )
115+ cmdutil .StringEnumFlag (cmd , & opts .GitProtocol , "git-protocol" , "p" , "" , []string {"ssh" , "https" }, "The protocol to use for git operations" )
114116
115117 return cmd
116118}
@@ -186,6 +188,7 @@ func loginRun(opts *LoginOptions) error {
186188 Web : opts .Web ,
187189 Scopes : opts .Scopes ,
188190 Executable : opts .MainExecutable ,
191+ GitProtocol : opts .GitProtocol ,
189192 })
190193}
191194
0 commit comments