diff --git a/cmd/plugins.go b/cmd/plugins.go index 0308125..812b5a8 100644 --- a/cmd/plugins.go +++ b/cmd/plugins.go @@ -18,6 +18,9 @@ import ( var pluginsCmd = &cobra.Command{ Use: "plugins", 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{ @@ -89,7 +92,7 @@ var pluginsCompileCmd = &cobra.Command{ }, } -var pluginInspectCmd = &cobra.Command{ +var pluginsInspectCmd = &cobra.Command{ Use: "inspect", Args: cobra.MinimumNArgs(1), Example: ` @@ -120,7 +123,7 @@ var pluginInspectCmd = &cobra.Command{ }, } -var pluginInfoCmd = &cobra.Command{ +var pluginsInfoCmd = &cobra.Command{ Use: "info", Short: "Show plugin information", Args: cobra.MinimumNArgs(1), @@ -159,6 +162,7 @@ var pluginInfoCmd = &cobra.Command{ Any("status", map[string]any{ "code": res.StatusCode, "message": res.Status, + "body": string(body), }). Str("host", host). Msg("response returned bad status") @@ -174,8 +178,10 @@ var pluginInfoCmd = &cobra.Command{ } func init() { - pluginsCompileCmd.Flags().StringP("output", "o", "", "Set the path to save compiled plugin") - pluginsCmd.AddCommand(pluginsCompileCmd, pluginInspectCmd, pluginInfoCmd) + pluginsCompileCmd.PersistentFlags().StringP("output", "o", "", "Set the path to save compiled plugin") + 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) }