fix: issue with host not being set for plugins cmd

This commit is contained in:
David Allen 2025-08-30 00:13:05 -06:00
parent 0f6f8957f6
commit 73498a08de
Signed by: towk
GPG key ID: 0430CDBE22619155

View file

@ -18,6 +18,9 @@ import (
var pluginsCmd = &cobra.Command{ var pluginsCmd = &cobra.Command{
Use: "plugins", Use: "plugins",
Short: "Manage, inspect, and compile plugins (requires Go build tools)", Short: "Manage, inspect, and compile plugins (requires Go build tools)",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
setenv(cmd, "host", "MAKESHIFT_HOST")
},
} }
var pluginsCompileCmd = &cobra.Command{ var pluginsCompileCmd = &cobra.Command{
@ -89,7 +92,7 @@ var pluginsCompileCmd = &cobra.Command{
}, },
} }
var pluginInspectCmd = &cobra.Command{ var pluginsInspectCmd = &cobra.Command{
Use: "inspect", Use: "inspect",
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
Example: ` Example: `
@ -120,7 +123,7 @@ var pluginInspectCmd = &cobra.Command{
}, },
} }
var pluginInfoCmd = &cobra.Command{ var pluginsInfoCmd = &cobra.Command{
Use: "info", Use: "info",
Short: "Show plugin information", Short: "Show plugin information",
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
@ -159,6 +162,7 @@ var pluginInfoCmd = &cobra.Command{
Any("status", map[string]any{ Any("status", map[string]any{
"code": res.StatusCode, "code": res.StatusCode,
"message": res.Status, "message": res.Status,
"body": string(body),
}). }).
Str("host", host). Str("host", host).
Msg("response returned bad status") Msg("response returned bad status")
@ -174,8 +178,10 @@ var pluginInfoCmd = &cobra.Command{
} }
func init() { func init() {
pluginsCompileCmd.Flags().StringP("output", "o", "", "Set the path to save compiled plugin") pluginsCompileCmd.PersistentFlags().StringP("output", "o", "", "Set the path to save compiled plugin")
pluginsCmd.AddCommand(pluginsCompileCmd, pluginInspectCmd, pluginInfoCmd) pluginsInfoCmd.PersistentFlags().String("host", "http://localhost:5050", "Set the makeshift remote host (can be set with MAKESHIFT_HOST)")
pluginsCmd.AddCommand(pluginsCompileCmd, pluginsInspectCmd, pluginsInfoCmd)
rootCmd.AddCommand(pluginsCmd) rootCmd.AddCommand(pluginsCmd)
} }