Add function to stub commands

I used this pattern on [pair](https://github.com/rylnd/dotfiles) to stub out some network calls in tests, but it's a pretty powerful 

I already did the work so I figured I'd open it up to discussion. Does this seem useful?