diff --git a/cmd/ai.go b/cmd/other/ai.go similarity index 95% rename from cmd/ai.go rename to cmd/other/ai.go index 70b0cf3..6cdb163 100644 --- a/cmd/ai.go +++ b/cmd/other/ai.go @@ -1,4 +1,4 @@ -package cmd +package other import ( "bufio" @@ -22,8 +22,8 @@ var ( resourceDir = filepath.Join(os.Getenv("HOME"), ".cfctl", "training_data") ) -// aiCmd represents the ai command -var aiCmd = &cobra.Command{ +// AiCmd represents the ai command +var AiCmd = &cobra.Command{ Use: "ai", Short: "Run AI-powered tasks", Long: `Run various AI-powered tasks, including general text processing or natural language @@ -266,12 +266,12 @@ func queryAIWithContext(query, contextData string) (string, error) { } func init() { - aiCmd.Flags().String("input", "", "Input text for the AI to process") - aiCmd.Flags().BoolP("natural", "n", false, "Enable natural language mode for the AI") + AiCmd.Flags().String("input", "", "Input text for the AI to process") + AiCmd.Flags().BoolP("natural", "n", false, "Enable natural language mode for the AI") aiChatCmd.Flags().StringP("query", "q", "", "Query text for the AI to process") aiChatCmd.MarkFlagRequired("query") - // Add config command as a subcommand to aiCmd - aiCmd.AddCommand(aiConfigCmd) - aiCmd.AddCommand(aiChatCmd) + // Add config command as a subcommand to AiCmd + AiCmd.AddCommand(aiConfigCmd) + AiCmd.AddCommand(aiChatCmd) } diff --git a/cmd/apiResources.go b/cmd/other/apiResources.go similarity index 99% rename from cmd/apiResources.go rename to cmd/other/apiResources.go index a37add6..7aa5d60 100644 --- a/cmd/apiResources.go +++ b/cmd/other/apiResources.go @@ -1,6 +1,6 @@ // apiResources.go -package cmd +package other import ( "context" @@ -32,7 +32,7 @@ import ( var endpoints string -var apiResourcesCmd = &cobra.Command{ +var ApiResourcesCmd = &cobra.Command{ Use: "api-resources", Short: "Displays supported API resources", Run: func(cmd *cobra.Command, args []string) { @@ -471,5 +471,5 @@ func splitIntoLinesWithComma(text string, maxWidth int) []string { } func init() { - apiResourcesCmd.Flags().StringVarP(&endpoints, "service", "s", "", "Specify the services to connect to, separated by commas (e.g., 'identity', 'identity,inventory')") + ApiResourcesCmd.Flags().StringVarP(&endpoints, "service", "s", "", "Specify the services to connect to, separated by commas (e.g., 'identity', 'identity,inventory')") } diff --git a/cmd/config.go b/cmd/other/config.go similarity index 98% rename from cmd/config.go rename to cmd/other/config.go index 4dcbb36..991749f 100644 --- a/cmd/config.go +++ b/cmd/other/config.go @@ -1,6 +1,6 @@ // config.go -package cmd +package other import ( "encoding/json" @@ -26,8 +26,8 @@ var availableServices = []string{ "cost_analysis", "board", "file_manager", "dashboard", } -// configCmd represents the config command -var configCmd = &cobra.Command{ +// ConfigCmd represents the config command +var ConfigCmd = &cobra.Command{ Use: "config", Short: "Manage cfctl configuration files", Long: `Manage configuration files for cfctl. You can initialize, @@ -476,12 +476,12 @@ func parseEnvNameFromURL(urlStr string) (string, error) { } func init() { - // Adding subcommands to configCmd - configCmd.AddCommand(configInitCmd) - configCmd.AddCommand(envCmd) - configCmd.AddCommand(showCmd) - configCmd.AddCommand(configEndpointCmd) - configCmd.AddCommand(syncCmd) + // Adding subcommands to ConfigCmd + ConfigCmd.AddCommand(configInitCmd) + ConfigCmd.AddCommand(envCmd) + ConfigCmd.AddCommand(showCmd) + ConfigCmd.AddCommand(configEndpointCmd) + ConfigCmd.AddCommand(syncCmd) // Defining flags for configInitCmd configInitCmd.Flags().StringP("environment", "e", "", "Override environment name") diff --git a/cmd/exec.go b/cmd/other/exec.go similarity index 96% rename from cmd/exec.go rename to cmd/other/exec.go index 779163a..ba79aaf 100644 --- a/cmd/exec.go +++ b/cmd/other/exec.go @@ -1,4 +1,4 @@ -package cmd +package other import ( "bytes" @@ -45,7 +45,7 @@ type Environment struct { Token string `yaml:"token"` } -var execCmd = &cobra.Command{ +var ExecCmd = &cobra.Command{ Use: "exec [rpc] [service].[resource]", Short: "Execute a gRPC request to a specified service and message", Long: `Executes a gRPC command to a given service and message based on environment configuration. @@ -405,10 +405,10 @@ func printCSV(data map[string]interface{}) string { } func init() { - execCmd.Flags().StringArrayVarP(¶meters, "parameter", "p", []string{}, "Input Parameter (-p = -p ...)") - execCmd.Flags().StringVarP(&jsonParameter, "json-parameter", "j", "", "JSON type parameter") - execCmd.Flags().StringVarP(&fileParameter, "file-parameter", "f", "", "YAML file parameter") - execCmd.Flags().StringVarP(&apiVersion, "api-version", "v", "v1", "API Version") - execCmd.Flags().StringVarP(&outputFormat, "output", "o", "yaml", "Output format (yaml, json, table, csv)") - execCmd.Flags().BoolVarP(©ToClipboard, "copy", "c", false, "Copy the output to the clipboard (copies any output format)") + ExecCmd.Flags().StringArrayVarP(¶meters, "parameter", "p", []string{}, "Input Parameter (-p = -p ...)") + ExecCmd.Flags().StringVarP(&jsonParameter, "json-parameter", "j", "", "JSON type parameter") + ExecCmd.Flags().StringVarP(&fileParameter, "file-parameter", "f", "", "YAML file parameter") + ExecCmd.Flags().StringVarP(&apiVersion, "api-version", "v", "v1", "API Version") + ExecCmd.Flags().StringVarP(&outputFormat, "output", "o", "yaml", "Output format (yaml, json, table, csv)") + ExecCmd.Flags().BoolVarP(©ToClipboard, "copy", "c", false, "Copy the output to the clipboard (copies any output format)") } diff --git a/cmd/login.go b/cmd/other/login.go similarity index 98% rename from cmd/login.go rename to cmd/other/login.go index db1b5e1..46f2a12 100644 --- a/cmd/login.go +++ b/cmd/other/login.go @@ -1,4 +1,4 @@ -package cmd +package other import ( "bufio" @@ -21,8 +21,8 @@ import ( var providedUrl string -// loginCmd represents the login command -var loginCmd = &cobra.Command{ +// LoginCmd represents the login command +var LoginCmd = &cobra.Command{ Use: "login", Short: "Login to SpaceONE", Long: `A command that allows you to login to SpaceONE. @@ -604,6 +604,6 @@ func selectScopeOrWorkspace(workspaces []map[string]interface{}) string { } func init() { - loginCmd.Flags().StringVarP(&providedUrl, "url", "u", "", "The URL to use for login (e.g. cfctl login -u https://example.com)") - //loginCmd.MarkFlagRequired("url") + LoginCmd.Flags().StringVarP(&providedUrl, "url", "u", "", "The URL to use for login (e.g. cfctl login -u https://example.com)") + //LoginCmd.MarkFlagRequired("url") } diff --git a/cmd/root.go b/cmd/root.go index 72c9f19..0c70426 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -6,6 +6,8 @@ package cmd import ( "os" + "github.com/cloudforet-io/cfctl/cmd/other" + "github.com/spf13/cobra" ) @@ -40,11 +42,11 @@ func init() { } rootCmd.AddGroup(OtherCommands) - rootCmd.AddCommand(aiCmd) - rootCmd.AddCommand(apiResourcesCmd) - rootCmd.AddCommand(configCmd) - rootCmd.AddCommand(execCmd) - rootCmd.AddCommand(loginCmd) + rootCmd.AddCommand(other.AiCmd) + rootCmd.AddCommand(other.ApiResourcesCmd) + rootCmd.AddCommand(other.ConfigCmd) + rootCmd.AddCommand(other.ExecCmd) + rootCmd.AddCommand(other.LoginCmd) for _, cmd := range rootCmd.Commands() { if cmd.Name() != "help" && cmd.Name() != "completion" {