Refactor help system to consolidate error messages and command-specific help
- Simplify main help to show brief command descriptions only - Add --help support to all commands with detailed usage information - Replace duplicated help text in error messages with error + help pattern - Remove 'help' command in favor of consistent --help flag usage - Add helper functions CheckForHelpFlag() and ShowErrorWithHelp() for standardization - Refactor deploy command to reduce cognitive complexity and improve maintainability 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
59dd709d83
commit
dee239a3d4
11 changed files with 370 additions and 80 deletions
27
plugin.go
27
plugin.go
|
@ -114,3 +114,30 @@ func ParsePluginCtlConfig(manifest *model.Manifest) (*PluginCtlConfig, error) {
|
|||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
const (
|
||||
HelpFlagLong = "--help"
|
||||
HelpFlagShort = "-h"
|
||||
)
|
||||
|
||||
// CheckForHelpFlag checks if --help is in the arguments and shows help if found.
|
||||
// Returns true if help was shown, false otherwise.
|
||||
func CheckForHelpFlag(args []string, helpText string) bool {
|
||||
for _, arg := range args {
|
||||
if arg == HelpFlagLong || arg == HelpFlagShort {
|
||||
Logger.Info(helpText)
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// ShowErrorWithHelp displays an error message followed by command help.
|
||||
func ShowErrorWithHelp(errorMsg, helpText string) error {
|
||||
Logger.Error(errorMsg)
|
||||
Logger.Info(helpText)
|
||||
|
||||
return fmt.Errorf("%s", errorMsg)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue