enhancement: streamline command handling and enhance help output
This pull request improves the command-line interface of the mcp-publisher tool by adding enhanced help and usage messages for both global and command-specific contexts. It introduces structured help output for each command and refactors argument parsing for better clarity and maintainability.
Improvements to CLI help and usage:
- Added support for global
--help,-h,help,--version,-v, andversionflags, displaying usage or version information as appropriate. - Introduced command-specific help output via a new
printCommandHelpfunction, providing detailed usage, descriptions, options, and examples for each command (init,login,logout,publish).
Refactoring and maintainability:
- Refactored argument parsing by extracting the command and its arguments from
os.Args, simplifying subsequent command handling and making the code more readable. - Updated error messages and help prompts to use the extracted command variable, ensuring consistency in user feedback.
Motivation and Context
How Has This Been Tested?
Breaking Changes
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation update
Checklist
- [x] I have read the MCP Documentation
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [ ] I have added or updated documentation as needed
Additional context
#735This pull request improves the command-line interface of the mcp-publisher tool by enhancing how help and version information is handled and by adding detailed, command-specific help messages. The changes make the tool more user-friendly and provide clearer guidance for each command.
Improvements to CLI argument handling and help output:
- Refactored the main command parsing logic in
cmd/publisher/main.goto handle global--help,-h,help,--version,-v, andversionflags before dispatching to subcommands, ensuring consistent behavior and output for these flags. - Added support for displaying command-specific help when
--help,-h, orhelpis passed as the first argument to any subcommand, improving discoverability of command usage.
Addition of detailed command-specific help:
- Implemented a new
printCommandHelpfunction incmd/publisher/main.gothat provides detailed usage, descriptions, options, and examples for each supported command (init,login,logout,publish), making it easier for users to understand and use each command correctly.