10quality / wpmvc-commands

Ayuco commands for Wordpress MVC,
MIT License
2 stars 4 forks source link

Preserve Newlines when running PrettifyCommand #86

Open garretthyder opened 4 years ago

garretthyder commented 4 years ago

Hello @amostajo,

Testing the PrettifyCommand I found it stripped all empty lines from my code causing everything to be bunched together and harder to read. It would be nice if it's possible to keep newlines preserved.

Thanks

amostajo commented 4 years ago

@garretthyder Sorry, have been a bit busy the past days, will resume checking on these issues.

amostajo commented 4 years ago

@garretthyder Can you please show the piece of syntax that didn't preserve the new lines?

garretthyder commented 4 years ago

Hi @amostajo no worries, sorry for my delayed response.

Here's the before/after of the prettify command on my in progress project; https://gist.github.com/garretthyder/07f2729b6a297cd100d386aa6bb00446

The first thing to note is the new lines between code gets stripped as does some that was surrounding functions.

Also note some oddities that occur with the conditional becoming multi-line and only one of the add_assets becoming multiline.

amostajo commented 4 years ago

Umm, ok lets review what we can do, in the meantime you can user option --nopretty to preserve your double lines.

Example:

php ayuco add:init ConfigController@init --nopretty --comment="Configuration settings."
amostajo commented 4 years ago

Btw...

For this:

$this->add_action( 'admin_menu', 'AdminController@menu' );

Try the addon: https://github.com/10quality/wpmvc-addon-administrator

garretthyder commented 4 years ago

Thanks @amostajo sounds good, I'll use nopretty for the time being.

And that addon looks awesome, I'll delve in and add it to my roadmap for a future update.