Skip to content

Commit 4e85a19

Browse files
committed
add autostop cmd for debugging
1 parent 8abdd00 commit 4e85a19

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

pkg/cmd/autostop/autostop.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package autostop
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
6+
"github.com/brevdev/brev-cli/pkg/entity"
7+
breverrors "github.com/brevdev/brev-cli/pkg/errors"
8+
"github.com/brevdev/brev-cli/pkg/terminal"
9+
)
10+
11+
var (
12+
short = "TODO"
13+
long = "TODO"
14+
example = "TODO"
15+
)
16+
17+
func NewCmdautostop(t *terminal.Terminal, store autostopStore) *cobra.Command {
18+
cmd := &cobra.Command{
19+
Use: "autostop",
20+
DisableFlagsInUseLine: true,
21+
Short: short,
22+
Long: long,
23+
Example: example,
24+
RunE: func(cmd *cobra.Command, args []string) error {
25+
err := Runautostop(
26+
runAutostopArgs{
27+
t: t,
28+
args: args,
29+
store: store,
30+
},
31+
)
32+
if err != nil {
33+
return breverrors.WrapAndTrace(err)
34+
}
35+
return nil
36+
},
37+
}
38+
return cmd
39+
}
40+
41+
type autostopStore interface {
42+
AutoStopWorkspace(workspaceID string) (*entity.Workspace, error)
43+
}
44+
45+
type runAutostopArgs struct {
46+
t *terminal.Terminal
47+
args []string
48+
store autostopStore
49+
}
50+
51+
func Runautostop(args runAutostopArgs) error {
52+
_, err := args.store.AutoStopWorkspace(args.args[0])
53+
return breverrors.WrapAndTrace(err)
54+
}

0 commit comments

Comments
 (0)