MCPcopy Index your code
hub / github.com/coder/coder / favorite

Method favorite

cli/favorite.go:11–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9)
10
11func (r *RootCmd) favorite() *serpent.Command {
12 cmd := &serpent.Command{
13 Aliases: []string{"fav", "favou" + "rite"},
14 Annotations: workspaceCommand,
15 Use: "favorite <workspace>",
16 Short: "Add a workspace to your favorites",
17 Middleware: serpent.Chain(
18 serpent.RequireNArgs(1),
19 ),
20 Handler: func(inv *serpent.Invocation) error {
21 client, err := r.InitClient(inv)
22 if err != nil {
23 return err
24 }
25
26 ws, err := client.ResolveWorkspace(inv.Context(), inv.Args[0])
27 if err != nil {
28 return xerrors.Errorf("get workspace: %w", err)
29 }
30
31 if err := client.FavoriteWorkspace(inv.Context(), ws.ID); err != nil {
32 return xerrors.Errorf("favorite workspace: %w", err)
33 }
34 _, _ = fmt.Fprintf(inv.Stdout, "Workspace %q added to favorites.\n", ws.Name)
35 return nil
36 },
37 }
38 return cmd
39}
40
41func (r *RootCmd) unfavorite() *serpent.Command {
42 cmd := &serpent.Command{

Callers 1

CoreSubcommandsMethod · 0.95

Calls 5

InitClientMethod · 0.95
ResolveWorkspaceMethod · 0.80
ContextMethod · 0.65
FavoriteWorkspaceMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected