pluginctl/disable.go
Felipe Martin dee239a3d4
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>
2025-07-28 19:20:36 +02:00

43 lines
1,020 B
Go

package pluginctl
import (
"context"
"fmt"
"github.com/mattermost/mattermost/server/public/model"
)
func RunDisableCommand(args []string, pluginPath string) error {
helpText := `Disable plugin in Mattermost server
Usage:
pluginctl disable [options]
Options:
--help, -h Show this help message
Description:
Disables the plugin in the connected Mattermost server. The plugin will
remain uploaded but will be inactive.
Examples:
pluginctl disable # Disable plugin from current directory
pluginctl --plugin-path /path/to/plugin disable # Disable plugin at specific path`
// Check for help flag
if CheckForHelpFlag(args, helpText) {
return nil
}
return runPluginCommand(args, pluginPath, disablePlugin)
}
func disablePlugin(ctx context.Context, client *model.Client4, pluginID string) error {
Logger.Info("Disabling plugin")
_, err := client.DisablePlugin(ctx, pluginID)
if err != nil {
return fmt.Errorf("failed to disable plugin: %w", err)
}
return nil
}