vendredi 10 avril 2015

Rails generators :: colorize output and raise exceptions

I’m currently writing more or less sophisticated rails generator. It’s quite straightforward, save for a lack of documentation. I see that internal methods (came from Thor, AFAIU,) like create_file and others colorize their output:


create: app/policies/application_policy.rb


On the other hand, I could not find any appearance of the code handling this colorization during my quick-walk-through open source generators (like rails-default, pundit, devise, etc.) I expect this functionality to be exported, smth like say WARN, 'You are doing it wrong'.


Another minor question: is it indeed necessary to handle all the errors manually, print out a message and gracefully exit instead of raising some kind of rails-generators-aware standard exception?!


Any suggestions on what am I missing are strongly appreciated.


Aucun commentaire:

Enregistrer un commentaire