Right now, you have to have the desired data in the region, I'd like for it to default to the whole buffer if the region isn't active (but there is no shell-command-on-buffer function in elisp, on the the region-oriented one).
Perhaps . . .
(if (not (region-exists-p))
Update: You might want to do a save-excursion
before that so you don't leave it marked afterwards. Of course
it's been so long since I even tried diddling with elisp
I can't remember if that's recommended or not.