Skip to content

Commit

Permalink
Fail on incomplete command
Browse files Browse the repository at this point in the history
  • Loading branch information
strokyl committed Mar 20, 2024
1 parent 252f186 commit 6e9429d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (client *Client) Delete(kind, name string) error {
}

func (client *Client) GetOpenApi() ([]byte, error) {
url := client.baseUrl + "public/docs/docs.yaml"
url := client.baseUrl + "/public/docs/docs.yaml"
resp, err := client.client.R().Get(url)
if err != nil {
return nil, err
Expand Down
12 changes: 9 additions & 3 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import (
var getCmd = &cobra.Command{
Use: "get",
Short: "get resource of a given kind",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
// Root command does nothing
cmd.Help()
os.Exit(1)
},
}

var getCmdWhenNoSchema = &cobra.Command{
Expand All @@ -35,17 +41,17 @@ will describe the application myapp`,
}

func initGet() {
rootCmd.AddCommand(getCmd)
if schemaClient == nil {
getCmd.AddCommand(getCmdWhenNoSchema)
rootCmd.AddCommand(getCmdWhenNoSchema)
return
}
tags, err := schemaClient.GetKind()
if err != nil {
fmt.Fprintf(os.Stderr, "Could not load kind from openapi: %s\n", err)
getCmd.AddCommand(getCmdWhenNoSchema)
rootCmd.AddCommand(getCmdWhenNoSchema)
return
}
rootCmd.AddCommand(getCmd)

for _, tag := range tags {
tagCmd := &cobra.Command{
Expand Down
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ You can also use the CDK_KEY,CDK_CERT instead of --key and --cert flags to use a
apiClient.ActivateDebug()
}
},
Run: func(cmd *cobra.Command, args []string) {
// Root command does nothing
cmd.Help()
os.Exit(1)
},
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
Expand Down

0 comments on commit 6e9429d

Please sign in to comment.