Implement support for optional command arguments.

Fixes #5933