Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make other directory and specify commands to Other Commands #35

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions cmd/ai.go → cmd/other/ai.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package other

import (
"bufio"
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
6 changes: 3 additions & 3 deletions cmd/apiResources.go → cmd/other/apiResources.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// apiResources.go

package cmd
package other

import (
"context"
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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')")
}
18 changes: 9 additions & 9 deletions cmd/config.go → cmd/other/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// config.go

package cmd
package other

import (
"encoding/json"
Expand All @@ -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,
Expand Down Expand Up @@ -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")
Expand Down
16 changes: 8 additions & 8 deletions cmd/exec.go → cmd/other/exec.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package other

import (
"bytes"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -405,10 +405,10 @@ func printCSV(data map[string]interface{}) string {
}

func init() {
execCmd.Flags().StringArrayVarP(&parameters, "parameter", "p", []string{}, "Input Parameter (-p <key>=<value> -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(&copyToClipboard, "copy", "c", false, "Copy the output to the clipboard (copies any output format)")
ExecCmd.Flags().StringArrayVarP(&parameters, "parameter", "p", []string{}, "Input Parameter (-p <key>=<value> -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(&copyToClipboard, "copy", "c", false, "Copy the output to the clipboard (copies any output format)")
}
10 changes: 5 additions & 5 deletions cmd/login.go → cmd/other/login.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package other

import (
"bufio"
Expand All @@ -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.
Expand Down Expand Up @@ -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")
}
12 changes: 7 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package cmd
import (
"os"

"github.com/cloudforet-io/cfctl/cmd/other"

"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -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" {
Expand Down
Loading