2

Every-time I tried to build the generate-all command it prompts me to Overwrite?[y,n,a] for input. Is there a way to select 'y' by default.

Edit: I am setting up framework for the first time and I am frequently changing the model and generate views and controllers to check.

Update: select option 'a' and it will automatically override all the files instead of prompting every time.

Bhuwan Gautam
  • 1,229
  • 1
  • 11
  • 24
  • 4
    As I said below, you should be able to pass `--non-interactive` but it's ignored in these scripts. Fortunately they're now in the scaffolding plugin, so if you report an issue at https://jira.grails.org/browse/GPSCAFFOLD I'll fix this and release an updated plugin. – Burt Beckwith Jan 15 '15 at 13:45
  • Yes, as you have said it's not working but i read the document. Thanks for the detail. – Bhuwan Gautam Jan 15 '15 at 14:32

3 Answers3

3

In case you landed here via google.

New grails (3.x) has "-force" option to regenerate generated files

$ grails generate-all bookstore.Author                                                                               
Warning |                                                                                                            
Destination file grails-app\controllers\bookstore\AuthorController.groovy already exists, skipping...                
Warning |                                                                                                            
Destination file src\test\groovy\bookstore\AuthorControllerSpec.groovy already exists, skipping...                   
Warning |                                                                                                            
Destination file grails-app\views\author\edit.gsp already exists, skipping...                                        
Warning |                                                                                                            
Destination file grails-app\views\author\create.gsp already exists, skipping...                                      
Warning |                                                                                                            
Destination file grails-app\views\author\index.gsp already exists, skipping...                                       
Warning |                                                                                                            
Destination file grails-app\views\author\show.gsp already exists, skipping...                                        
|Scaffolding completed for grails-app\domain\bookstore\Author.groovy                                                 


$ grails generate-all -force bookstore.Author                                                                        
|Rendered template Controller.groovy to destination grails-app\controllers\bookstore\AuthorController.groovy         
|Rendered template Spec.groovy to destination src\test\groovy\bookstore\AuthorControllerSpec.groovy                  
|Rendered template edit.gsp to destination grails-app\views\author\edit.gsp                                          
|Rendered template create.gsp to destination grails-app\views\author\create.gsp                                      
|Rendered template index.gsp to destination grails-app\views\author\index.gsp                                        
|Rendered template show.gsp to destination grails-app\views\author\show.gsp                                          
|Scaffolding completed for grails-app\domain\bookstore\Author.groovy                                                 
Jayan
  • 18,003
  • 15
  • 89
  • 143
1

No there is no option to do that, as this prompt is to protect the existing code from being accidentally overwritten.

Can you please elaborate your needs and reason for doing this, so that anyone can provide you with an alternative?

Chetan
  • 1,707
  • 10
  • 17
  • 3
    Have you heard of the `--non-interactive` switch? It's described in the docs here: http://grails.org/doc/latest/guide/commandLine.html It's designed for exactly this scenario, when you want a script to run and just accept defaults and assume yes answers. Unfortunately the generate scripts don't check for its existence, but that's a bug that should be fixed. – Burt Beckwith Jan 15 '15 at 13:41
  • 1
    Thank you so much for adding in with your comment Burt. – Chetan Jan 16 '15 at 07:55
1

In Grails Version: 3.2.8 The command is $ grails generate-all bookstore.Author -force

Usman
  • 949
  • 9
  • 12