Refactor CLISubCommand.

- Design so that it is possible to be thread-safe.
- Try to minimize the number of functions.
- Make better choice of name and API.