Skip to content

Commit d6b25ee

Browse files
authored
Merge pull request #483 from dgageot/simpler-commands
Simpler code for cobra commands
2 parents b560484 + 53d8458 commit d6b25ee

5 files changed

Lines changed: 3 additions & 25 deletions

File tree

cmd/root/catalog.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ func NewCatalogCmd() *cobra.Command {
2020
cmd := &cobra.Command{
2121
Use: "catalog",
2222
Short: "Manage the agent catalog",
23-
RunE: func(cmd *cobra.Command, args []string) error {
24-
return cmd.Help()
25-
},
2623
}
2724

2825
cmd.AddCommand(newCatalogListCmd())
@@ -31,7 +28,7 @@ func NewCatalogCmd() *cobra.Command {
3128
}
3229

3330
func newCatalogListCmd() *cobra.Command {
34-
cmd := &cobra.Command{
31+
return &cobra.Command{
3532
Use: "list [org]",
3633
Short: "List catalog entries",
3734
Args: cobra.MaximumNArgs(1),
@@ -49,8 +46,6 @@ func newCatalogListCmd() *cobra.Command {
4946
return listCatalog(cmd.Context(), org)
5047
},
5148
}
52-
53-
return cmd
5449
}
5550

5651
type hubRepoList struct {

cmd/root/pull.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
func NewPullCmd() *cobra.Command {
18-
cmd := &cobra.Command{
18+
return &cobra.Command{
1919
Use: "pull <registry-ref>",
2020
Short: "Pull an artifact from Docker Hub",
2121
Long: `Pull an artifact from Docker Hub`,
@@ -25,8 +25,6 @@ func NewPullCmd() *cobra.Command {
2525
return runPullCommand(args[0])
2626
},
2727
}
28-
29-
return cmd
3028
}
3129

3230
func runPullCommand(registryRef string) error {

cmd/root/push.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func NewPushCmd() *cobra.Command {
17-
cmd := &cobra.Command{
17+
return &cobra.Command{
1818
Use: "push <agent file> <reference>",
1919
Short: "Push an agent to an OCI registry",
2020
Long: `Push an agent to an OCI registry.
@@ -27,8 +27,6 @@ from the build command.`,
2727
return runPushCommand(args[0], args[1])
2828
},
2929
}
30-
31-
return cmd
3230
}
3331

3432
func runPushCommand(filePath, tag string) error {

cmd/root/root.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ func NewRootCmd() *cobra.Command {
109109
cmd.AddCommand(NewVersionCmd())
110110
cmd.AddCommand(NewRunCmd())
111111
cmd.AddCommand(NewExecCmd())
112-
cmd.AddCommand(NewTuiCmd())
113112
cmd.AddCommand(NewNewCmd())
114113
cmd.AddCommand(NewAPICmd())
115114
cmd.AddCommand(NewEvalCmd())

cmd/root/run.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,6 @@ func NewRunCmd() *cobra.Command {
8080
return cmd
8181
}
8282

83-
func NewTuiCmd() *cobra.Command {
84-
return &cobra.Command{
85-
Use: "tui",
86-
Short: "Deprecated. Use `cagent run` instead.",
87-
Hidden: true,
88-
RunE: func(cmd *cobra.Command, args []string) error {
89-
fmt.Fprintln(os.Stderr, "'cagent tui' is deprecated. Please use 'cagent run' instead.")
90-
return nil
91-
},
92-
}
93-
}
94-
9583
func runCommand(cmd *cobra.Command, args []string) error {
9684
telemetry.TrackCommand("run", args)
9785
return doRunCommand(cmd.Context(), args, false)

0 commit comments

Comments
 (0)