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

[GitHub models] Rename models root command #9

Merged
merged 2 commits into from
Oct 10, 2024
Merged
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
8 changes: 7 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ import (
"github.com/github/gh-models/cmd/list"
"github.com/github/gh-models/cmd/run"
"github.com/spf13/cobra"
"strings"
)

func NewRootCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "gh models",
Use: "models",
Short: "GitHub Models extension",
}

cmd.AddCommand(list.NewListCommand())
cmd.AddCommand(run.NewRunCommand())

// Cobra doesn't have a way to specify a two word command (ie. "gh models"), so set a custom usage template
// with `gh`` in it. Cobra will use this template for the root and all child commands.
cmd.SetUsageTemplate(strings.NewReplacer(
"{{.UseLine}}", "gh {{.UseLine}}",
"{{.CommandPath}}", "gh {{.CommandPath}}").Replace(cmd.UsageTemplate()))
return cmd
}