Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] Add destroy compliment to generator commands #188

Open
drujensen opened this issue Aug 25, 2017 · 13 comments
Open

[CLI] Add destroy compliment to generator commands #188

drujensen opened this issue Aug 25, 2017 · 13 comments

Comments

@drujensen
Copy link
Member

amber g controller Post will create src/controllers/post.cr
amber d controller Post should delete src/controllers/post.cr

Do the same for scaffolding and the rest of the generators.

@eliasjpr
Copy link
Contributor

Was this already address?

@elorest
Copy link
Member

elorest commented Aug 31, 2017 via email

@marksiemers
Copy link
Contributor

I think this could and should be done in teeplate. I believe the relevant starting points are:
here: https://github.com/mosop/teeplate/blob/master/src/lib/renderer.cr#L47
and here: https://github.com/mosop/teeplate/blob/master/src/lib/rendering_entry.cr#L57

I've opened an issue here: mosop/teeplate#8

@elorest
Copy link
Member

elorest commented Nov 12, 2017 via email

@marksiemers
Copy link
Contributor

Not a priority, but still a good feature. I love the destroy functionality.

One typo with a scaffold and you're spending 10 minutes deleting files (or worse, NOT deleting them at all).

I usually run a scaffold about 3 times before I have it right.

If the Teeplate maintainer puts it in, then it should be an easy add for us at that point.

@marksiemers
Copy link
Contributor

@amberframework/core-team - There is a fix for this in teeplate, but mosop isn't maintaining it anymore.

If we switch to the amberframework fork of this, we can incorporate the work that @aaronstillwell has done.

@eliasjpr eliasjpr modified the milestones: Version 0.7.0, Version 0.6.9 Feb 10, 2018
@eliasjpr eliasjpr changed the title Add destroy compliment to generator commands [CLI] Add destroy compliment to generator commands Feb 10, 2018
@eliasjpr
Copy link
Contributor

Whats the status of this? Has this been resolved by pointing to Amber Fork?

@aaronstillwell
Copy link

@eliasjpr the fork of teeplate is now at https://github.com/amberframework/teeplate, so we'll get the necessary changes up and running there asap. See https://github.com/amberframework/teeplate/pull/2 for the discussion specific to the necessary behaviour for a destroy command.

@marksiemers
Copy link
Contributor

@eliasjpr - I think amber will require a change to get this functionality complete in amber.

For files like:

...
07:30:59 Generate   | (INFO) skipped   spec/models/spec_helper.cr
...
07:30:59 Generate   | (INFO) skipped   spec/controllers/spec_helper.cr
...

There needs to be logic that does not destroy those files (in this example for destroying a scaffold).

@eliasjpr
Copy link
Contributor

Agree, I think we can skip those files, after all there are just there to shorten the require. I don't think that we should delete or modify these files contents

@damianham
Copy link
Contributor

damianham commented Mar 30, 2018

In order to support a delete option we really need to roll back to previous versions of any files that were modified during the generate stage. If this functionality is to reduce the effort to remove a set of files that were created with the scaffold generator then there is an easier way. I don't have this problem because I order my code in modules using damianham/amber_render_module so to rollback for example:

amber g scaffold Post tutle:string body:text

because I misspelt title I simple type

rm -rf src/modules/post spec/modules/post db/migrations/*create_post.sql

and remove the 2 lines from src/views/layouts/_nav.slang.

@faustinoaq
Copy link
Contributor

Some update on this?, looks like https://github.com/amberframework/teeplate/pull/2 is already accepted, not merged, though.

@drujensen
Copy link
Member Author

One option is to leverage git and rollback to the previous sha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants