66 dc "github.com/dockware/dockware-cli/dockercompose"
77 "github.com/spf13/cobra"
88 "golang.org/x/term"
9+ "log"
910 "os"
1011 "os/exec"
1112 "strings"
@@ -29,9 +30,8 @@ var creatorCmd = &cobra.Command{
2930 Short : "Use the interactive dockware creator to get what you need for today's task" ,
3031 Long : "" ,
3132 Run : func (cmd * cobra.Command , args []string ) {
32- if ! term .IsTerminal (int (syscall .Stdin )) {
33- fmt .Println ("interactive terminal required" )
34- os .Exit (1 )
33+ if ! term .IsTerminal (syscall .Stdin ) {
34+ log .Fatal ("interactive terminal required" )
3535 }
3636
3737 a := & Answers {}
@@ -41,7 +41,7 @@ var creatorCmd = &cobra.Command{
4141 case dc .Play :
4242
4343 a .SwVersion = askShopwareVersion (dc .Play .String ())
44- runArgs := []string {"run" , "--rm" , "--name" , "shopware" , "-p" , "80:80" , "-p" , "443:443" , fmt .Sprintf ("dockware/%s:%s" , a .DevIntentString , a .SwVersion )}
44+ runArgs := []string {"run" , "--rm" , "--name" , "shopware" , "-p" , "80:80" , "-p" , "443:443" , fmt .Sprintf ("dockware/%s:%s" , a .DevIntentString , a .SwVersion )}
4545
4646 fmt .Printf ("All done! Just run the following command in your terminal and enjoy Shopware %s:\n \n " , a .SwVersion )
4747 fmt .Printf ("docker %s\n \n " , strings .Join (runArgs , " " ))
@@ -50,8 +50,7 @@ var creatorCmd = &cobra.Command{
5050 Message : "Run the command now?" ,
5151 }, & execute )
5252 if err != nil {
53- fmt .Printf ("%s\n " , err .Error ())
54- os .Exit (1 )
53+ log .Fatalf ("%s\n " , err .Error ())
5554 }
5655 if execute {
5756 cmd := exec .Command ("docker" , runArgs ... )
@@ -60,8 +59,7 @@ var creatorCmd = &cobra.Command{
6059 cmd .Stdout = os .Stdout
6160 err := cmd .Run ()
6261 if err != nil {
63- fmt .Println (err .Error ())
64- os .Exit (1 )
62+ log .Fatal (err .Error ())
6563 }
6664 }
6765 return
@@ -80,14 +78,12 @@ var creatorCmd = &cobra.Command{
8078
8179 composeString , err := dc .BuildDockware ("dev" , dc .MountType (a .MountType ), swVersion , withMySQL , withElastic , withRedis , withAppServer , withPWA )
8280 if err != nil {
83- fmt .Printf ("could not build YAML: %s\n " , err .Error ())
84- os .Exit (1 )
81+ log .Fatalf ("could not build YAML: %s\n " , err .Error ())
8582 }
8683
8784 err = os .WriteFile ("docker-compose.yml" , []byte (composeString ), 0666 )
8885 if err != nil {
89- fmt .Printf ("could not write file: %s\n " , err .Error ())
90- os .Exit (1 )
86+ log .Fatalf ("could not write file: %s\n " , err .Error ())
9187 }
9288
9389 fmt .Println ("File generated: ./docker-compose.yml" )
@@ -99,13 +95,12 @@ var creatorCmd = &cobra.Command{
9995
10096 composeString , err := dc .BuildDockware ("contribute" , dc .MountType (a .MountType ), "latest" , false , false , false , false , false )
10197 if err != nil {
102- fmt . Errorf ("could not build YAML: %s\n " , err .Error ())
98+ log . Fatalf ("could not build YAML: %s\n " , err .Error ())
10399 }
104100
105101 err = os .WriteFile ("docker-compose.yml" , []byte (composeString ), 0666 )
106102 if err != nil {
107- fmt .Printf ("could not write file: %s\n " , err .Error ())
108- os .Exit (1 )
103+ log .Fatalf ("could not write file: %s\n " , err .Error ())
109104 }
110105
111106 fmt .Println ("File generated: ./docker-compose.yml" )
@@ -143,8 +138,7 @@ func (a *Answers) getDevType() {
143138
144139 err := survey .Ask (devTypeQuestion , a )
145140 if err != nil {
146- fmt .Println (err .Error ())
147- os .Exit (1 )
141+ log .Fatal (err .Error ())
148142 }
149143}
150144
@@ -174,8 +168,7 @@ func (a *Answers) getMountType() {
174168 }
175169 err := survey .Ask (asMountType , a )
176170 if err != nil {
177- fmt .Println (err .Error ())
178- os .Exit (1 )
171+ log .Fatal (err .Error ())
179172 }
180173}
181174
@@ -186,7 +179,7 @@ func (a *Answers) getDevIntent() {
186179 dc .Contribute : "Best for contributing changes to the Shopware core" ,
187180 }
188181 imageTitles := make ([]string , len (images ))
189- for i , _ := range images {
182+ for i := range images {
190183 it := dc .DevIntent (i )
191184 imageTitles [i ] = it .String ()
192185 }
@@ -205,8 +198,7 @@ func (a *Answers) getDevIntent() {
205198 }
206199 err := survey .Ask (askImage , a )
207200 if err != nil {
208- fmt .Printf ("Could not get Dev Intent: %s\n " , err .Error ())
209- os .Exit (1 )
201+ log .Fatalf ("Could not get Dev Intent: %s\n " , err .Error ())
210202 }
211203 a .DevIntentString = dc .DevIntent (a .DevIntent ).String ()
212204}
0 commit comments