Skip to content
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
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
prCmd "github.com/tyrantkhan/bb/cmd/pr"
repoCmd "github.com/tyrantkhan/bb/cmd/repo"
searchCmd "github.com/tyrantkhan/bb/cmd/search"
workspaceCmd "github.com/tyrantkhan/bb/cmd/workspace"
"github.com/tyrantkhan/bb/internal/cmdutil"
"github.com/tyrantkhan/bb/internal/output"
"github.com/tyrantkhan/bb/internal/update"
Expand Down Expand Up @@ -119,6 +120,7 @@ func NewRootCommand() *cli.Command {
prCmd.NewCmdPR(),
pipelineCmd.NewCmdPipeline(),
searchCmd.NewCmdSearch(),
workspaceCmd.NewCmdWorkspace(),
{
Name: "version",
Aliases: []string{"v"},
Expand Down
58 changes: 58 additions & 0 deletions cmd/workspace/members.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package workspace

import (
"context"
"fmt"

"github.com/tyrantkhan/bb/internal/api"
"github.com/tyrantkhan/bb/internal/cmdutil"
"github.com/tyrantkhan/bb/internal/models"
"github.com/tyrantkhan/bb/internal/output"
"github.com/urfave/cli/v3"
)

func newCmdMembers() *cli.Command {
return &cli.Command{
Name: "members",
Usage: "List members in a workspace",
Flags: []cli.Flag{
cmdutil.WorkspaceFlag,
cmdutil.FormatFlag,
cmdutil.LimitFlag,
},
Action: cmdutil.NoArgs(func(ctx context.Context, cmd *cli.Command) error {
f := cmdutil.GetFactory(ctx)
client, err := f.APIClient()
if err != nil {
return err
}

workspace, err := cmdutil.ResolveWorkspace(ctx, cmd)
if err != nil {
return err
}

limit := int(cmd.Int("limit"))
path := fmt.Sprintf("/2.0/workspaces/%s/members", workspace)

members, err := api.Paginate[models.WorkspaceMembership](client, path, limit)
if err != nil {
return err
}

format := cmdutil.GetFormat(ctx, cmd)

headers := []string{"Display Name", "Nickname", "Account ID"}
rows := make([][]string, len(members))
for i, m := range members {
rows[i] = []string{
m.User.DisplayName,
m.User.Nickname,
m.User.AccountID,
}
}

return output.Format(format, members, headers, rows)
}),
}
}
18 changes: 18 additions & 0 deletions cmd/workspace/workspace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package workspace

import (
"github.com/tyrantkhan/bb/internal/cmdutil"
"github.com/urfave/cli/v3"
)

// NewCmdWorkspace returns the parent workspace command with its subcommands.
func NewCmdWorkspace() *cli.Command {
return &cli.Command{
Name: "workspace",
Usage: "Manage workspaces",
CommandNotFound: cmdutil.CommandNotFound,
Commands: []*cli.Command{
newCmdMembers(),
},
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tyrantkhan/bb

go 1.26.1
go 1.26.2

require (
charm.land/glamour/v2 v2.0.0-20260302162937-86f90cfe96d1
Expand Down
7 changes: 7 additions & 0 deletions internal/models/workspace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package models

// WorkspaceMembership represents a member's membership in a workspace.
type WorkspaceMembership struct {
User User `json:"user"`
Workspace Workspace `json:"workspace"`
}
Loading