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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.12"
".": "0.1.0-alpha.13"
}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.1.0-alpha.13 (2025-06-17)

Full Changelog: [v0.1.0-alpha.12...v0.1.0-alpha.13](https://github.com/stainless-api/stainless-api-cli/compare/v0.1.0-alpha.12...v0.1.0-alpha.13)

### Chores

* **ci:** enable for pull requests ([3539b82](https://github.com/stainless-api/stainless-api-cli/commit/3539b82e2606cc2252ed808bf4feff883cab21c8))
* **internal:** codegen related update ([567a6e6](https://github.com/stainless-api/stainless-api-cli/commit/567a6e653a6ca70db50cf9cc80ac6deaa64be97a))

## 0.1.0-alpha.12 (2025-06-16)

Full Changelog: [v0.1.0-alpha.11...v0.1.0-alpha.12](https://github.com/stainless-api/stainless-api-cli/compare/v0.1.0-alpha.11...v0.1.0-alpha.12)
Expand Down
12 changes: 10 additions & 2 deletions cmd/stl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ package main

import (
"context"
"log"
"errors"
"fmt"
"os"

"github.com/stainless-api/stainless-api-cli/pkg/cmd"
"github.com/stainless-api/stainless-api-go"
)

func main() {
app := cmd.Command
if err := app.Run(context.Background(), os.Args); err != nil {
log.Fatal(err)
var apierr *stainlessv0.Error
if errors.As(err, &apierr) {
fmt.Printf("%s\n", cmd.ColorizeJSON(apierr.RawJSON(), os.Stderr))
} else {
fmt.Printf("%s\n", err.Error())
}
os.Exit(1)
}
}
2 changes: 1 addition & 1 deletion pkg/cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func pollForToken(clientID, deviceCode string, interval, expiresIn int) (*AuthCo
}

// GetClientOptions returns the request options for API calls
func getClientOptions(ctx context.Context, cmd *cli.Command) []option.RequestOption {
func getClientOptions() []option.RequestOption {
options := []option.RequestOption{}

if apiKey := os.Getenv("STAINLESS_API_KEY"); apiKey != "" {
Expand Down
9 changes: 4 additions & 5 deletions pkg/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,7 @@ func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error {
}
}

// Print the actual JSON response to stdout for piping
fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
return nil
}

Expand All @@ -414,7 +413,7 @@ func handleBuildsRetrieve(ctx context.Context, cmd *cli.Command) error {
return err
}

fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
return nil
}

Expand Down Expand Up @@ -573,7 +572,7 @@ func handleBuildsList(ctx context.Context, cmd *cli.Command) error {
return err
}

fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
return nil
}

Expand All @@ -589,7 +588,7 @@ func handleBuildsCompare(ctx context.Context, cmd *cli.Command) error {
return err
}

fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/buildtargetoutput.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func handleBuildsTargetOutputsRetrieve(ctx context.Context, cmd *cli.Command) er
return err
}

fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))

if cmd.Bool("pull") {
build, err := cc.client.Builds.Get(ctx, cmd.String("build-id"))
Expand All @@ -74,5 +74,6 @@ func handleBuildsTargetOutputsRetrieve(ctx context.Context, cmd *cli.Command) er
targetDir := fmt.Sprintf("%s-%s", build.Project, cmd.String("target"))
return pullOutput(res.Output, res.URL, res.Ref, targetDir)
}

return nil
}
6 changes: 6 additions & 0 deletions pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import (
var Command = cli.Command{
Name: "stl",
Usage: "CLI for the stainless API",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "debug",
Usage: "Enable debug logging",
},
},
Commands: []*cli.Command{
{
Name: "auth",
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func handleOrgsRetrieve(ctx context.Context, cmd *cli.Command) error {
return err
}

fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
return nil
}

Expand All @@ -53,6 +53,6 @@ func handleOrgsList(ctx context.Context, cmd *cli.Command) error {
return err
}

fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
return nil
}
10 changes: 4 additions & 6 deletions pkg/cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,12 @@ func handleProjectsCreate(ctx context.Context, cmd *cli.Command) error {
context.TODO(),
params,
option.WithMiddleware(cc.AsMiddleware()),
option.WithRequestBody("application/json", cc.body),
)
if err != nil {
return err
}

fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
return nil
}

Expand All @@ -150,7 +149,7 @@ func handleProjectsRetrieve(ctx context.Context, cmd *cli.Command) error {
return err
}

fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
return nil
}

Expand All @@ -164,13 +163,12 @@ func handleProjectsUpdate(ctx context.Context, cmd *cli.Command) error {
context.TODO(),
params,
option.WithMiddleware(cc.AsMiddleware()),
option.WithRequestBody("application/json", cc.body),
)
if err != nil {
return err
}

fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
return nil
}

Expand All @@ -186,6 +184,6 @@ func handleProjectsList(ctx context.Context, cmd *cli.Command) error {
return err
}

fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
return nil
}
5 changes: 2 additions & 3 deletions pkg/cmd/projectbranch.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ func handleProjectsBranchesCreate(ctx context.Context, cmd *cli.Command) error {
context.TODO(),
params,
option.WithMiddleware(cc.AsMiddleware()),
option.WithRequestBody("application/json", cc.body),
)
if err != nil {
return err
}

fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
return nil
}

Expand All @@ -97,6 +96,6 @@ func handleProjectsBranchesRetrieve(ctx context.Context, cmd *cli.Command) error
return err
}

fmt.Printf("%s\n", colorizeJSON(res.RawJSON(), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout))
return nil
}
5 changes: 2 additions & 3 deletions pkg/cmd/projectconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func handleProjectsConfigsRetrieve(ctx context.Context, cmd *cli.Command) error
return err
}

fmt.Printf("%s\n", colorizeJSON(string(res), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(string(res), os.Stdout))
return nil
}

Expand All @@ -90,13 +90,12 @@ func handleProjectsConfigsGuess(ctx context.Context, cmd *cli.Command) error {
context.TODO(),
params,
option.WithMiddleware(cc.AsMiddleware()),
option.WithRequestBody("application/json", cc.body),
option.WithResponseBodyInto(&res),
)
if err != nil {
return err
}

fmt.Printf("%s\n", colorizeJSON(string(res), os.Stdout))
fmt.Printf("%s\n", ColorizeJSON(string(res), os.Stdout))
return nil
}
Loading
Loading