44 "fmt"
55 _url "net/url"
66 "os"
7+ "strings"
78 "time"
89
910 "github.com/adohkan/git-remote-https-iap/internal/git"
@@ -30,14 +31,19 @@ var (
3031 versionCmd = & cobra.Command {
3132 Use : "version" ,
3233 Short : "Print version number" ,
33- Run : func (cmd * cobra.Command , args []string ) {
34- fmt .Printf ("%s %s\n " , BinaryName , version )
35- },
34+ Run : printVersion ,
35+ }
36+
37+ installProtocolCmd = & cobra.Command {
38+ Use : "install" ,
39+ Short : "Install protocol in Git config" ,
40+ Run : installGitProtocol ,
3641 }
3742)
3843
3944func init () {
4045 rootCmd .AddCommand (versionCmd )
46+ rootCmd .AddCommand (installProtocolCmd )
4147
4248 // set default log level
4349 zerolog .SetGlobalLevel (zerolog .DebugLevel )
@@ -58,6 +64,16 @@ func execute(cmd *cobra.Command, args []string) {
5864 git .PassThruRemoteHTTPSHelper (remote , url )
5965}
6066
67+ func printVersion (cmd * cobra.Command , args []string ) {
68+ fmt .Printf ("%s %s\n " , BinaryName , version )
69+ }
70+
71+ func installGitProtocol (cmd * cobra.Command , args []string ) {
72+ p := strings .TrimLeft (BinaryName , "git-remote-" )
73+ git .InstallProtocol (p )
74+ log .Info ().Msgf ("%s protocol configured in git!" , p )
75+ }
76+
6177func handleIAPAuthCookieFor (url string ) {
6278 // All our work will be based on the basedomain of the provided URL
6379 // as IAP would be setup for the whole domain.
0 commit comments