I am trying to figure out how to add new runtime flags to commands that are run from the terminal.
For eg. : I have recently started experimenting with Docker and find it tedious to clean up exited containers by copy pasting IDs. I want to add a command line option
clean to the
docker runtime, so that when I run
docker clean (or perhaps
docker --clean if we're going that way) I can internally map it to run a cleanup command with already supported options by the docker runtime (namely
docker rm $(docker ps -a -q -f status=exited)) Is it possible to establish such a mapping?
I know one option is to use aliases, however aliases don't allow for having spaces / command line flags in the alias names, to the best of my knowledge. Similarly, shell functions don't help because they override the entire functionality (or perhaps I'm doing it wrong). I have wanted to explore this possibility for a while, so any help will be appreciated.