Skip to content

Commit e869ad2

Browse files
committed
fix our custom commands for stainless changes
1 parent 08a19d3 commit e869ad2

File tree

6 files changed

+32
-249
lines changed

6 files changed

+32
-249
lines changed

pkg/cmd/logs.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ func handleLogs(ctx context.Context, cmd *cli.Command) error {
5151
params.Tail = hypeman.Opt(int64(cmd.Int("tail")))
5252
}
5353

54+
var opts []option.RequestOption
55+
if cmd.Root().Bool("debug") {
56+
opts = append(opts, debugMiddlewareOption)
57+
}
58+
5459
stream := client.Instances.LogsStreaming(
5560
ctx,
5661
instanceID,
5762
params,
58-
option.WithMiddleware(debugMiddleware(cmd.Root().Bool("debug"))),
63+
opts...,
5964
)
6065
defer stream.Close()
6166

pkg/cmd/ps.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ var psCmd = cli.Command{
3232
func handlePs(ctx context.Context, cmd *cli.Command) error {
3333
client := hypeman.NewClient(getDefaultRequestOptions(cmd)...)
3434

35+
var opts []option.RequestOption
36+
if cmd.Root().Bool("debug") {
37+
opts = append(opts, debugMiddlewareOption)
38+
}
39+
3540
instances, err := client.Instances.List(
3641
ctx,
37-
option.WithMiddleware(debugMiddleware(cmd.Root().Bool("debug"))),
42+
opts...,
3843
)
3944
if err != nil {
4045
return err

pkg/cmd/pull.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,15 @@ func handlePull(ctx context.Context, cmd *cli.Command) error {
3434
Name: image,
3535
}
3636

37+
var opts []option.RequestOption
38+
if cmd.Root().Bool("debug") {
39+
opts = append(opts, debugMiddlewareOption)
40+
}
41+
3742
result, err := client.Images.New(
3843
ctx,
3944
params,
40-
option.WithMiddleware(debugMiddleware(cmd.Root().Bool("debug"))),
45+
opts...,
4146
)
4247
if err != nil {
4348
return err

pkg/cmd/rm.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,18 @@ func handleRm(ctx context.Context, cmd *cli.Command) error {
7373
}
7474
}
7575

76+
// Build debug options once
77+
var opts []option.RequestOption
78+
if cmd.Root().Bool("debug") {
79+
opts = append(opts, debugMiddlewareOption)
80+
}
81+
7682
// Check instance state if not forcing
7783
if !force {
7884
inst, err := client.Instances.Get(
7985
ctx,
8086
instanceID,
81-
option.WithMiddleware(debugMiddleware(cmd.Root().Bool("debug"))),
87+
opts...,
8288
)
8389
if err != nil {
8490
fmt.Printf("Error: failed to get instance %s: %v\n", instanceID, err)
@@ -101,7 +107,7 @@ func handleRm(ctx context.Context, cmd *cli.Command) error {
101107
err = client.Instances.Delete(
102108
ctx,
103109
instanceID,
104-
option.WithMiddleware(debugMiddleware(cmd.Root().Bool("debug"))),
110+
opts...,
105111
)
106112
if err != nil {
107113
fmt.Printf("Error: failed to remove instance %s: %v\n", instanceID, err)

pkg/cmd/run.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,15 @@ func handleRun(ctx context.Context, cmd *cli.Command) error {
120120

121121
fmt.Fprintf(os.Stderr, "Creating instance %s...\n", name)
122122

123+
var opts []option.RequestOption
124+
if cmd.Root().Bool("debug") {
125+
opts = append(opts, debugMiddlewareOption)
126+
}
127+
123128
result, err := client.Instances.New(
124129
ctx,
125130
params,
126-
option.WithMiddleware(debugMiddleware(cmd.Root().Bool("debug"))),
131+
opts...,
127132
)
128133
if err != nil {
129134
return err

pkg/cmd/util.go

Lines changed: 0 additions & 243 deletions
This file was deleted.

0 commit comments

Comments
 (0)