Add manifest command with subcommands for plugin information
- Add manifest command with id, version, has_server, has_webapp subcommands - Provides simple text output for easy parsing/scripting - Update help documentation with usage examples - Follow existing command patterns and architecture 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3cbe5e4a9f
commit
c01c9c2843
2 changed files with 70 additions and 0 deletions
|
@ -54,6 +54,10 @@ func runCommand(command string, args []string, pluginPath string) error {
|
|||
return runResetCommand(args, pluginPath)
|
||||
case "updateassets":
|
||||
return runUpdateAssetsCommand(args, pluginPath)
|
||||
case "manifest":
|
||||
return runManifestCommand(args, pluginPath)
|
||||
case "logs":
|
||||
return runLogsCommand(args, pluginPath)
|
||||
case "help":
|
||||
showUsage()
|
||||
|
||||
|
@ -91,6 +95,14 @@ func runUpdateAssetsCommand(args []string, pluginPath string) error {
|
|||
return pluginctl.RunUpdateAssetsCommand(args, pluginPath)
|
||||
}
|
||||
|
||||
func runManifestCommand(args []string, pluginPath string) error {
|
||||
return pluginctl.RunManifestCommand(args, pluginPath)
|
||||
}
|
||||
|
||||
func runLogsCommand(args []string, pluginPath string) error {
|
||||
return pluginctl.RunLogsCommand(args, pluginPath)
|
||||
}
|
||||
|
||||
func showUsage() {
|
||||
usageText := `pluginctl - Mattermost Plugin Development CLI
|
||||
|
||||
|
@ -106,6 +118,8 @@ Commands:
|
|||
disable Disable plugin from current directory in Mattermost server
|
||||
reset Reset plugin from current directory (disable then enable)
|
||||
updateassets Update plugin files from embedded assets
|
||||
manifest Get plugin manifest information (id, version, has_server, has_webapp)
|
||||
logs View plugin logs (use --watch to follow logs in real-time)
|
||||
help Show this help message
|
||||
version Show version information
|
||||
|
||||
|
@ -116,6 +130,12 @@ Examples:
|
|||
pluginctl disable # Disable plugin from current directory
|
||||
pluginctl reset # Reset plugin from current directory (disable then enable)
|
||||
pluginctl updateassets # Update plugin files from embedded assets
|
||||
pluginctl manifest id # Get plugin ID
|
||||
pluginctl manifest version # Get plugin version
|
||||
pluginctl manifest has_server # Check if plugin has server code
|
||||
pluginctl manifest has_webapp # Check if plugin has webapp code
|
||||
pluginctl logs # View recent plugin logs
|
||||
pluginctl logs --watch # Watch plugin logs in real-time
|
||||
export PLUGINCTL_PLUGIN_PATH=/path/to/plugin
|
||||
pluginctl info # Show info using environment variable
|
||||
pluginctl version # Show version information
|
||||
|
|
50
manifest.go
Normal file
50
manifest.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package pluginctl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// RunManifestCommand implements the 'manifest' command functionality with subcommands.
|
||||
func RunManifestCommand(args []string, pluginPath string) error {
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("manifest command requires a subcommand: id, version, has_server, has_webapp")
|
||||
}
|
||||
|
||||
// Convert to absolute path
|
||||
absPath, err := filepath.Abs(pluginPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to resolve path: %w", err)
|
||||
}
|
||||
|
||||
// Load plugin manifest
|
||||
manifest, err := LoadPluginManifestFromPath(absPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to load plugin manifest: %w", err)
|
||||
}
|
||||
|
||||
subcommand := args[0]
|
||||
switch subcommand {
|
||||
case "id":
|
||||
fmt.Println(manifest.Id)
|
||||
case "version":
|
||||
fmt.Println(manifest.Version)
|
||||
case "has_server":
|
||||
if HasServerCode(manifest) {
|
||||
fmt.Println("true")
|
||||
} else {
|
||||
fmt.Println("false")
|
||||
}
|
||||
case "has_webapp":
|
||||
if HasWebappCode(manifest) {
|
||||
fmt.Println("true")
|
||||
} else {
|
||||
fmt.Println("false")
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unknown subcommand: %s. Available subcommands: id, version, has_server, has_webapp",
|
||||
subcommand)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue