Is it possible to call Git or other command line tools from inside a Thor script?
问题 I find that I'm often running a sequence of routine 'cleanup' tasks before and after I make a git commit for my Rails 3 app. I was thinking about putting these things into a Thor script, but one thing I haven't been able to figure out is how to use Thor (or Rake) to call other tools on the system. Is it possible to call a command like git log from a Thor or Rake script, and if so what does that look like? Thanks! 回答1: Just shell out: result = %x(git log) puts result or system('git log') if