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

Change available commands to other commands #34

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
3 changes: 1 addition & 2 deletions cmd/ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
var (
apiToken string
configPath = filepath.Join(os.Getenv("HOME"), ".cfctl", "config")
resourceDir = filepath.Join(os.Getenv("HOME"), ".cfctl", "training_data") // 학습 전용 디렉터리 경로
resourceDir = filepath.Join(os.Getenv("HOME"), ".cfctl", "training_data")
)

// aiCmd represents the ai command
Expand Down Expand Up @@ -266,7 +266,6 @@ func queryAIWithContext(query, contextData string) (string, error) {
}

func init() {
rootCmd.AddCommand(aiCmd)
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")
Expand Down
1 change: 0 additions & 1 deletion cmd/apiResources.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,5 @@ func splitIntoLinesWithComma(text string, maxWidth int) []string {
}

func init() {
rootCmd.AddCommand(apiResourcesCmd)
apiResourcesCmd.Flags().StringVarP(&endpoints, "service", "s", "", "Specify the services to connect to, separated by commas (e.g., 'identity', 'identity,inventory')")
}
2 changes: 0 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,6 @@ func parseEnvNameFromURL(urlStr string) (string, error) {
}

func init() {
rootCmd.AddCommand(configCmd)

// Adding subcommands to configCmd
configCmd.AddCommand(configInitCmd)
configCmd.AddCommand(envCmd)
Expand Down
19 changes: 9 additions & 10 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ var execCmd = &cobra.Command{
Run: runExecCommand,
}

func init() {
rootCmd.AddCommand(execCmd)
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)")
}

func loadConfig() (*Config, error) {
configPath := fmt.Sprintf("%s/.cfctl/config.yaml", os.Getenv("HOME"))
data, err := os.ReadFile(configPath)
Expand Down Expand Up @@ -413,3 +403,12 @@ func printCSV(data map[string]interface{}) string {
}
return ""
}

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)")
}
1 change: 0 additions & 1 deletion cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ func selectScopeOrWorkspace(workspaces []map[string]interface{}) string {
}

func init() {
rootCmd.AddCommand(loginCmd)
loginCmd.Flags().StringVarP(&providedUrl, "url", "u", "", "The URL to use for login (e.g. cfctl login -u https://example.com)")
//loginCmd.MarkFlagRequired("url")
}
22 changes: 16 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,21 @@ func Execute() {
}

func init() {
// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
OtherCommands := &cobra.Group{
ID: "other",
Title: "Other Commands:",
}
rootCmd.AddGroup(OtherCommands)

rootCmd.AddCommand(aiCmd)
rootCmd.AddCommand(apiResourcesCmd)
rootCmd.AddCommand(configCmd)
rootCmd.AddCommand(execCmd)
rootCmd.AddCommand(loginCmd)

// Cobra also supports local flags, which will only run
// when this action is called directly.
//rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
for _, cmd := range rootCmd.Commands() {
if cmd.Name() != "help" && cmd.Name() != "completion" {
cmd.GroupID = "other"
}
}
}
Loading