Skip to content

Commit

Permalink
Group API key commands in help output
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamon committed May 2, 2024
1 parent 31c6c32 commit 3c279bb
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 6 deletions.
3 changes: 3 additions & 0 deletions internal/pkg/cli/command/project/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ func NewProjectCmd() *cobra.Command {
GroupID: help.GROUP_MANAGEMENT.ID,
}

cmd.AddGroup(help.GROUP_PROJECTS_CRUD)
cmd.AddGroup(help.GROUP_PROJECTS_API_KEYS)

cmd.AddCommand(NewListProjectsCmd())
cmd.AddCommand(NewCreateProjectCmd())
cmd.AddCommand(NewDeleteProjectCmd())
Expand Down
5 changes: 3 additions & 2 deletions internal/pkg/cli/command/project/create-key.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ func NewCreateApiKeyCmd() *cobra.Command {
options := CreateApiKeyOptions{}

cmd := &cobra.Command{
Use: "create-key",
Short: "create an API key in a project",
Use: "create-key",
Short: "create an API key in a project",
GroupID: help.GROUP_PROJECTS_API_KEYS.ID,
Example: help.Examples([]string{
"pinecone target -o \"my-org\" -p \"my-project\"",
"pinecone create-key -n \"my-key\" --reveal",
Expand Down
5 changes: 3 additions & 2 deletions internal/pkg/cli/command/project/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ func NewCreateProjectCmd() *cobra.Command {
options := CreateProjectCmdOptions{}

cmd := &cobra.Command{
Use: "create",
Short: "create a project in the target org",
Use: "create",
Short: "create a project in the target org",
GroupID: help.GROUP_PROJECTS_CRUD.ID,
Example: help.Examples([]string{
"pinecone target -o \"my-org\"",
"pinecone project create --name=\"demo\"",
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/cli/command/project/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func NewDeleteProjectCmd() *cobra.Command {
"pinecone project delete --name=\"demo\"",
"pinecone project delete --name=\"demo\" --yes",
}),
GroupID: help.GROUP_PROJECTS_CRUD.ID,
Run: func(cmd *cobra.Command, args []string) {
orgId, err := getTargetOrgId()
orgName := state.TargetOrg.Get().Name
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/cli/command/project/list-keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func NewListKeysCmd() *cobra.Command {
"pinecone target -o \"my-org\" -p \"my-project\"",
"pinecone list-keys --reveal",
}),
GroupID: help.GROUP_PROJECTS_API_KEYS.ID,
Run: func(cmd *cobra.Command, args []string) {
projId, err := getTargetProjectId()
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions internal/pkg/cli/command/project/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/pinecone-io/cli/internal/pkg/dashboard"
"github.com/pinecone-io/cli/internal/pkg/utils/configuration/state"
"github.com/pinecone-io/cli/internal/pkg/utils/help"
"github.com/pinecone-io/cli/internal/pkg/utils/style"
"github.com/spf13/cobra"

Expand All @@ -27,8 +28,9 @@ func NewListProjectsCmd() *cobra.Command {
options := ListProjectCmdOptions{}

cmd := &cobra.Command{
Use: "list",
Short: "list projects in the target org",
Use: "list",
Short: "list projects in the target org",
GroupID: help.GROUP_PROJECTS_CRUD.ID,
Run: func(cmd *cobra.Command, args []string) {
orgs, err := dashboard.ListOrganizations()
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions internal/pkg/utils/help/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ var (
ID: "index",
Title: style.Heading("Management Commands"),
}

GROUP_PROJECTS_API_KEYS = &cobra.Group{
ID: "keys",
Title: style.Heading("API Key Management"),
}

GROUP_PROJECTS_CRUD = &cobra.Group{
ID: "projects",
Title: style.Heading("Project Management"),
}
)

0 comments on commit 3c279bb

Please sign in to comment.