auto register main command, formatting, refactor