@@ -59,11 +59,22 @@ func (r *PackageInstallCommand) Extend() command.Extend {
5959 Category : "package" ,
6060 Flags : []command.Flag {
6161 & command.BoolFlag {
62- Name : "all-facades " ,
62+ Name : "all" ,
6363 Usage : "Install all facades" ,
6464 Aliases : []string {"a" },
6565 Value : false ,
6666 },
67+ & command.BoolFlag {
68+ Name : "default" ,
69+ Usage : "Install facades with default drivers" ,
70+ Aliases : []string {"d" },
71+ Value : false ,
72+ },
73+ & command.BoolFlag {
74+ Name : "dev" ,
75+ Usage : "Install drivers with the master branch" ,
76+ Value : false ,
77+ },
6778 },
6879 }
6980}
@@ -73,7 +84,7 @@ func (r *PackageInstallCommand) Handle(ctx console.Context) error {
7384 names := ctx .Arguments ()
7485
7586 if len (names ) == 0 {
76- if ctx .OptionBool ("all-facades " ) {
87+ if ctx .OptionBool ("all" ) {
7788 names = getAvailableFacades (r .bindings )
7889 } else {
7990 var err error
@@ -160,6 +171,10 @@ func (r *PackageInstallCommand) inputThirdPackage(ctx console.Context) (string,
160171}
161172
162173func (r * PackageInstallCommand ) installPackage (ctx console.Context , pkg string ) error {
174+ if ! strings .Contains (pkg , "@" ) && ctx .OptionBool ("dev" ) {
175+ pkg += "@master"
176+ }
177+
163178 pkgPath , _ , _ := strings .Cut (pkg , "@" )
164179 setup := pkgPath + "/setup"
165180
@@ -169,7 +184,7 @@ func (r *PackageInstallCommand) installPackage(ctx console.Context, pkg string)
169184 }
170185
171186 // install package
172- if err := supportconsole .ExecuteCommand (ctx , exec .Command ("go" , "run" , setup , "install" , "--package-name =" + env .MainPath (), "--paths=" + r .paths )); err != nil {
187+ if err := supportconsole .ExecuteCommand (ctx , exec .Command ("go" , "run" , setup , "install" , "--main-path =" + env .MainPath (), "--paths=" + r .paths )); err != nil {
173188 return fmt .Errorf ("failed to install package: %s" , err )
174189 }
175190
@@ -192,7 +207,7 @@ func (r *PackageInstallCommand) installFacade(ctx console.Context, name string)
192207 }
193208
194209 bindingsToInstall := r .getBindingsToInstall (binding )
195- if len (bindingsToInstall ) > 0 && ! ctx .OptionBool ("all-facades " ) {
210+ if len (bindingsToInstall ) > 0 && ! ctx .OptionBool ("all" ) {
196211 facades := make ([]string , len (bindingsToInstall ))
197212 for i := range bindingsToInstall {
198213 facades [i ] = convert .BindingToFacade (bindingsToInstall [i ])
@@ -210,7 +225,7 @@ func (r *PackageInstallCommand) installFacade(ctx console.Context, name string)
210225 continue
211226 }
212227
213- if err := supportconsole .ExecuteCommand (ctx , exec .Command ("go" , "run" , setup , "install" , "--facade=" + facade , "--package-name =" + env .MainPath (), "--paths=" + r .paths )); err != nil {
228+ if err := supportconsole .ExecuteCommand (ctx , exec .Command ("go" , "run" , setup , "install" , "--facade=" + facade , "--main-path =" + env .MainPath (), "--paths=" + r .paths )); err != nil {
214229 return fmt .Errorf ("failed to install facade %s: %s" , facade , err .Error ())
215230 }
216231
@@ -271,27 +286,33 @@ func (r *PackageInstallCommand) installDriver(ctx console.Context, facade string
271286 Value : "Custom" ,
272287 })
273288
274- driver , err := ctx .Choice (fmt .Sprintf ("Select the %s driver to install" , facade ), options , console.ChoiceOption {
275- Description : fmt .Sprintf ("A driver is required for %s, please select one to install." , facade ),
276- })
277- if err != nil {
278- return err
279- }
280-
281- if driver == "Custom" {
282- driver , err = ctx .Ask (fmt .Sprintf ("Please enter the %s driver package" , facade ))
289+ var driver string
290+ if ctx .OptionBool ("default" ) {
291+ driver = options [0 ].Value
292+ } else {
293+ var err error
294+ driver , err = ctx .Choice (fmt .Sprintf ("Select the %s driver to install" , facade ), options , console.ChoiceOption {
295+ Description : fmt .Sprintf ("A driver is required for %s, please select one to install." , facade ),
296+ })
283297 if err != nil {
284298 return err
285299 }
286- }
287300
288- if driver == "" {
289- return r .installDriver (ctx , facade , bindingInfo )
301+ if driver == "Custom" {
302+ driver , err = ctx .Ask (fmt .Sprintf ("Please enter the %s driver package" , facade ))
303+ if err != nil {
304+ return err
305+ }
306+ }
307+
308+ if driver == "" {
309+ return r .installDriver (ctx , facade , bindingInfo )
310+ }
290311 }
291312
292313 if isInternalDriver (driver ) {
293314 setup := bindingInfo .PkgPath + "/setup"
294- if err := supportconsole .ExecuteCommand (ctx , exec .Command ("go" , "run" , setup , "install" , "--driver=" + driver , "--package-name =" + env .MainPath (), "--paths=" + r .paths )); err != nil {
315+ if err := supportconsole .ExecuteCommand (ctx , exec .Command ("go" , "run" , setup , "install" , "--driver=" + driver , "--main-path =" + env .MainPath (), "--paths=" + r .paths )); err != nil {
295316 return fmt .Errorf ("failed to install driver %s: %s" , driver , err .Error ())
296317 }
297318
0 commit comments