@@ -18,6 +18,7 @@ import (
1818 "net/http"
1919 "os"
2020 "path/filepath"
21+ "regexp"
2122 "runtime"
2223 "strings"
2324 "time"
@@ -33,7 +34,7 @@ func runInstall(cmd *cobra.Command, args []string) error { // NOSONAR
3334 cmd .SilenceUsage = true // set here so subcommands do not silence usage
3435 var err error
3536 binPath := viper .GetString ("bin" )
36- log .Debug ("runInstall: " , "args" , args , "binPath" , binPath )
37+ log .Debug ("runInstall" , "args" , args , "binPath" , binPath )
3738 skipPrompts , _ := cmd .Flags ().GetBool ("yes" )
3839 assetName , _ := cmd .Flags ().GetString ("asset" )
3940 destName , _ := cmd .Flags ().GetString ("name" )
@@ -130,14 +131,12 @@ func runInstall(cmd *cobra.Command, args []string) error { // NOSONAR
130131 log .Infof ("tmpFile: %v" , tmpFile .Name ())
131132
132133 // Write Download to File
133- _ , err = io .Copy (tmpFile , rc )
134- if err != nil {
134+ if _ , err := io .Copy (tmpFile , rc ); err != nil {
135135 return fmt .Errorf ("write File error: %w" , err )
136136 }
137137
138138 // Seek Back to Start of File
139- _ , err = tmpFile .Seek (0 , 0 )
140- if err != nil {
139+ if _ , err := tmpFile .Seek (0 , 0 ); err != nil {
141140 return fmt .Errorf ("seek error: %w" , err )
142141 }
143142
@@ -198,8 +197,7 @@ func runInstall(cmd *cobra.Command, args []string) error { // NOSONAR
198197 return nil
199198 }).
200199 Value (& destName )
201- err = form .Run ()
202- if err != nil {
200+ if err := form .Run (); err != nil {
203201 log .Fatalf ("Prompt failed %v" , err )
204202 }
205203 log .Debugf ("4 destName: %v" , destName )
@@ -228,8 +226,7 @@ func runInstall(cmd *cobra.Command, args []string) error { // NOSONAR
228226 return fmt .Errorf ("failed to read file: %w" , err )
229227 }
230228 // Write to destination with executable permissions
231- err = os .WriteFile (destPath , data , 0755 )
232- if err != nil {
229+ if err := os .WriteFile (destPath , data , 0755 ); err != nil {
233230 return fmt .Errorf ("failed to write file: %w" , err )
234231 }
235232 }
@@ -401,3 +398,13 @@ func ensureWinExt(destName string) string {
401398 }
402399 return destName
403400}
401+
402+ func parseRepository (repository string ) (owner , repo string , err error ) {
403+ var repoPattern = regexp .MustCompile (`^[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+$` )
404+
405+ if ! repoPattern .MatchString (repository ) {
406+ return "" , "" , fmt .Errorf ("repository must be in format: owner/repo" )
407+ }
408+ split := strings .Split (repository , "/" )
409+ return split [0 ], split [1 ], nil
410+ }
0 commit comments