diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1916b02..56c2389 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.49" + ".": "0.1.0-alpha.50" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index f8afb0a..e76dae0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 19 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-5c1008fd27f64bcde1a146a4158f1c3113b4e13437a4d880bd6811fb063cfcd6.yml -openapi_spec_hash: 9583f62164b5dc15b10051dad6a7fca4 -config_hash: e895f7992a607a15865ed026cbe5470d +configured_endpoints: 20 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-030e47a1bfd79a657974f5beddd685940ec04b1aa1786c3b2cb0f4610ad2b42c.yml +openapi_spec_hash: 33b337af28bcc1c9aa1a5218acf2a7fe +config_hash: 6b235571b537b4814a33a1008b443e36 diff --git a/CHANGELOG.md b/CHANGELOG.md index ed48a83..b26d4a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +## 0.1.0-alpha.50 (2025-10-23) + +Full Changelog: [v0.1.0-alpha.49...v0.1.0-alpha.50](https://github.com/stainless-api/stainless-api-cli/compare/v0.1.0-alpha.49...v0.1.0-alpha.50) + +### Features + +* arguments now have defaults and descriptions ([9b8d534](https://github.com/stainless-api/stainless-api-cli/commit/9b8d534c8b92ae4f03dda9ac12e80c0574a0642d)) +* Expose connection-specific decorated OAS ([abf1d87](https://github.com/stainless-api/stainless-api-cli/commit/abf1d87e0af1e8f77405873c1ddf36f5070f897c)) + + +### Bug Fixes + +* pass through context parameter correctly ([29182fd](https://github.com/stainless-api/stainless-api-cli/commit/29182fdae10f5f91e3b8d0f90234f4e330572c9d)) + + +### Chores + +* bump go sdk version ([358eed4](https://github.com/stainless-api/stainless-api-cli/commit/358eed41b58f7bacf6d5ce340795d251fa1803c3)) +* bump Go version ([84c6127](https://github.com/stainless-api/stainless-api-cli/commit/84c612747d1a22ee69d3ffca48f7c538b9b44896)) +* **internal:** codegen related update ([375ca6b](https://github.com/stainless-api/stainless-api-cli/commit/375ca6ba3c64a74577430abec867b1b9b7c2fe43)) + ## 0.1.0-alpha.49 (2025-10-06) Full Changelog: [v0.1.0-alpha.48...v0.1.0-alpha.49](https://github.com/stainless-api/stainless-api-cli/compare/v0.1.0-alpha.48...v0.1.0-alpha.49) diff --git a/go.mod b/go.mod index 3eed7ec..2acd868 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/stainless-api/stainless-api-cli -go 1.24.0 +go 1.25 require ( github.com/charmbracelet/bubbles v0.21.0 @@ -14,13 +14,13 @@ require ( github.com/logrusorgru/aurora/v4 v4.0.0 github.com/muesli/reflow v0.3.0 github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c - github.com/stainless-api/stainless-api-go v0.25.0 + github.com/stainless-api/stainless-api-go v0.26.0 github.com/tidwall/gjson v1.18.0 github.com/tidwall/pretty v1.2.1 github.com/tidwall/sjson v1.2.5 github.com/urfave/cli-docs/v3 v3.0.0-alpha6 github.com/urfave/cli/v3 v3.3.2 - golang.org/x/term v0.35.0 + golang.org/x/term v0.36.0 ) require ( @@ -55,6 +55,6 @@ require ( github.com/yuin/goldmark-emoji v1.0.5 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.13.0 // indirect - golang.org/x/sys v0.36.0 // indirect + golang.org/x/sys v0.37.0 // indirect golang.org/x/text v0.24.0 // indirect ) diff --git a/go.sum b/go.sum index 2c27d9b..e98e4db 100644 --- a/go.sum +++ b/go.sum @@ -99,8 +99,8 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/stainless-api/stainless-api-go v0.25.0 h1:zcKI6oXjvw7kK3LoLOwmIxAGT+KzxBlWRyeZUCZ4s4E= -github.com/stainless-api/stainless-api-go v0.25.0/go.mod h1:apIvLQZziUlztAHBzTCLwf2TepwlPV0fg7dy/HIrKf8= +github.com/stainless-api/stainless-api-go v0.26.0 h1:ujHAtKFexP6SbfZ3h6BpiFajo0e4IFu6C66RtPpOkQY= +github.com/stainless-api/stainless-api-go v0.26.0/go.mod h1:apIvLQZziUlztAHBzTCLwf2TepwlPV0fg7dy/HIrKf8= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= @@ -133,10 +133,10 @@ golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= -golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ= -golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA= +golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= +golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q= +golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss= golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/pkg/cmd/build.go b/pkg/cmd/build.go index 1ee00be..d78099a 100644 --- a/pkg/cmd/build.go +++ b/pkg/cmd/build.go @@ -228,14 +228,16 @@ var buildsCreate = cli.Command{ Usage: "Create a build, on top of a project branch, against a given input revision.", Flags: []cli.Flag{ &jsonflag.JSONStringFlag{ - Name: "project", + Name: "project", + Usage: "Project name", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "project", }, }, &jsonflag.JSONStringFlag{ - Name: "revision", + Name: "revision", + Usage: `A branch name, commit SHA, or merge command in the format "base..head"`, Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "revision", @@ -260,29 +262,34 @@ var buildsCreate = cli.Command{ Usage: "Pull the build outputs after completion (only works with --wait)", }, &jsonflag.JSONBoolFlag{ - Name: "allow-empty", + Name: "allow-empty", + Usage: "Whether to allow empty commits (no changes). Defaults to false.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "allow_empty", SetValue: true, }, + Value: false, }, &jsonflag.JSONStringFlag{ - Name: "branch", + Name: "branch", + Usage: "The project branch to use for the build. If not specified, the\nbranch is inferred from the `revision`, and will 400 when that\nis not possible.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "branch", }, }, &jsonflag.JSONStringFlag{ - Name: "commit-message", + Name: "commit-message", + Usage: "Optional commit message to use when creating a new commit.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "commit_message", }, }, &jsonflag.JSONStringFlag{ - Name: "targets", + Name: "targets", + Usage: "Optional list of SDK targets to build. If not specified, all configured\ntargets will be built.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "targets.#", @@ -297,7 +304,8 @@ var buildsCreate = cli.Command{ Hidden: true, }, &jsonflag.JSONStringFlag{ - Name: "+target", + Name: "+target", + Usage: "Optional list of SDK targets to build. If not specified, all configured\ntargets will be built.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "targets.-1", @@ -313,7 +321,8 @@ var buildsRetrieve = cli.Command{ Usage: "Retrieve a build by its ID.", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "build-id", + Name: "build-id", + Usage: "Build ID", }, }, Action: handleBuildsRetrieve, @@ -325,35 +334,41 @@ var buildsList = cli.Command{ Usage: "List user-triggered builds for a given project.", Flags: []cli.Flag{ &jsonflag.JSONStringFlag{ - Name: "project", + Name: "project", + Usage: "Project name", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "project", }, }, &jsonflag.JSONStringFlag{ - Name: "branch", + Name: "branch", + Usage: "Branch name", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "branch", }, }, &jsonflag.JSONStringFlag{ - Name: "cursor", + Name: "cursor", + Usage: "Pagination cursor from a previous response.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "cursor", }, }, &jsonflag.JSONFloatFlag{ - Name: "limit", + Name: "limit", + Usage: "Maximum number of builds to return, defaults to 10 (maximum: 100).", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "limit", }, + Value: 10, }, &jsonflag.JSONStringFlag{ - Name: "revision", + Name: "revision", + Usage: "A config commit SHA used for the build", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "revision", @@ -369,63 +384,72 @@ var buildsCompare = cli.Command{ Usage: "Create two builds whose outputs can be directly compared with each other.", Flags: []cli.Flag{ &jsonflag.JSONStringFlag{ - Name: "base.branch", + Name: "base.branch", + Usage: "Branch to use. When using a branch name as revision, this must match or be\nomitted.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "base.branch", }, }, &jsonflag.JSONStringFlag{ - Name: "base.revision", + Name: "base.revision", + Usage: `A branch name, commit SHA, or merge command in the format "base..head"`, Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "base.revision", }, }, &jsonflag.JSONStringFlag{ - Name: "base.commit_message", + Name: "base.commit_message", + Usage: "Optional commit message to use when creating a new commit.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "base.commit_message", }, }, &jsonflag.JSONStringFlag{ - Name: "head.branch", + Name: "head.branch", + Usage: "Branch to use. When using a branch name as revision, this must match or be\nomitted.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "head.branch", }, }, &jsonflag.JSONStringFlag{ - Name: "head.revision", + Name: "head.revision", + Usage: `A branch name, commit SHA, or merge command in the format "base..head"`, Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "head.revision", }, }, &jsonflag.JSONStringFlag{ - Name: "head.commit_message", + Name: "head.commit_message", + Usage: "Optional commit message to use when creating a new commit.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "head.commit_message", }, }, &jsonflag.JSONStringFlag{ - Name: "project", + Name: "project", + Usage: "Project name", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "project", }, }, &jsonflag.JSONStringFlag{ - Name: "targets", + Name: "targets", + Usage: "Optional list of SDK targets to build. If not specified, all configured\ntargets will be built.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "targets.#", }, }, &jsonflag.JSONStringFlag{ - Name: "+target", + Name: "+target", + Usage: "Optional list of SDK targets to build. If not specified, all configured\ntargets will be built.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "targets.-1", @@ -456,7 +480,7 @@ func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error { buildGroup := Info("Creating build...") params := stainless.BuildNewParams{} res, err := cc.client.Builds.New( - context.TODO(), + ctx, params, option.WithMiddleware(cc.AsMiddleware()), ) @@ -505,7 +529,7 @@ func handleBuildsRetrieve(ctx context.Context, cmd *cli.Command) error { } var res []byte _, err := cc.client.Builds.Get( - context.TODO(), + ctx, cmd.Value("build-id").(string), option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), @@ -798,7 +822,7 @@ func handleBuildsList(ctx context.Context, cmd *cli.Command) error { params := stainless.BuildListParams{} var res []byte _, err := cc.client.Builds.List( - context.TODO(), + ctx, params, option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), @@ -822,7 +846,7 @@ func handleBuildsCompare(ctx context.Context, cmd *cli.Command) error { params := stainless.BuildCompareParams{} var res []byte _, err := cc.client.Builds.Compare( - context.TODO(), + ctx, params, option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), diff --git a/pkg/cmd/builddiagnostic.go b/pkg/cmd/builddiagnostic.go index aa6ca7b..8733a25 100644 --- a/pkg/cmd/builddiagnostic.go +++ b/pkg/cmd/builddiagnostic.go @@ -18,38 +18,45 @@ var buildsDiagnosticsList = cli.Command{ Usage: "Get the list of diagnostics for a given build.", Flags: []cli.Flag{ &cli.StringFlag{ - Name: "build-id", + Name: "build-id", + Usage: "Build ID", }, &jsonflag.JSONStringFlag{ - Name: "cursor", + Name: "cursor", + Usage: "Pagination cursor from a previous response", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "cursor", }, }, &jsonflag.JSONFloatFlag{ - Name: "limit", + Name: "limit", + Usage: "Maximum number of diagnostics to return, defaults to 100 (maximum: 100)", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "limit", }, + Value: 100, }, &jsonflag.JSONStringFlag{ - Name: "severity", + Name: "severity", + Usage: "Includes the given severity and above (fatal > error > warning > note).", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "severity", }, }, &jsonflag.JSONStringFlag{ - Name: "targets", + Name: "targets", + Usage: "Optional list of language targets to filter diagnostics by", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "targets.#", }, }, &jsonflag.JSONStringFlag{ - Name: "+target", + Name: "+target", + Usage: "Optional list of language targets to filter diagnostics by", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "targets.-1", @@ -73,7 +80,7 @@ func handleBuildsDiagnosticsList(ctx context.Context, cmd *cli.Command) error { params := stainless.BuildDiagnosticListParams{} var res []byte _, err := cc.client.Builds.Diagnostics.List( - context.TODO(), + ctx, cmd.Value("build-id").(string), params, option.WithMiddleware(cc.AsMiddleware()), diff --git a/pkg/cmd/buildtargetoutput.go b/pkg/cmd/buildtargetoutput.go index 377a303..bb34ee2 100644 --- a/pkg/cmd/buildtargetoutput.go +++ b/pkg/cmd/buildtargetoutput.go @@ -21,7 +21,8 @@ var buildsTargetOutputsRetrieve = cli.Command{ Name: "pull", }, &jsonflag.JSONStringFlag{ - Name: "build-id", + Name: "build-id", + Usage: "Build ID", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "build_id", @@ -37,7 +38,8 @@ var buildsTargetOutputsRetrieve = cli.Command{ Value: "main", }, &jsonflag.JSONStringFlag{ - Name: "target", + Name: "target", + Usage: "SDK language target name", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "target", @@ -51,11 +53,13 @@ var buildsTargetOutputsRetrieve = cli.Command{ }, }, &jsonflag.JSONStringFlag{ - Name: "output", + Name: "output", + Usage: "Output format: url (download URL) or git (temporary access token).", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "output", }, + Value: "url", }, }, Action: handleBuildsTargetOutputsRetrieve, @@ -82,7 +86,7 @@ func handleBuildsTargetOutputsRetrieve(ctx context.Context, cmd *cli.Command) er } var resBytes []byte res, err := cc.client.Builds.TargetOutputs.Get( - context.TODO(), + ctx, params, option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&resBytes), diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index d5a957d..6bf4624 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -164,6 +164,13 @@ stl builds create --branch `, &lintCommand, + { + Name: "spec", + Category: "API RESOURCE", + Commands: []*cli.Command{ + &specRetrieveDecoratedSpec, + }, + }, { Name: "@manpages", Usage: "Generate documentation for 'man'", diff --git a/pkg/cmd/org.go b/pkg/cmd/org.go index 720492f..4163f80 100644 --- a/pkg/cmd/org.go +++ b/pkg/cmd/org.go @@ -43,7 +43,7 @@ func handleOrgsRetrieve(ctx context.Context, cmd *cli.Command) error { } var res []byte _, err := cc.client.Orgs.Get( - context.TODO(), + ctx, cmd.Value("org").(string), option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), @@ -66,7 +66,7 @@ func handleOrgsList(ctx context.Context, cmd *cli.Command) error { } var res []byte _, err := cc.client.Orgs.List( - context.TODO(), + ctx, option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), ) diff --git a/pkg/cmd/project.go b/pkg/cmd/project.go index bcf85fe..c319874 100644 --- a/pkg/cmd/project.go +++ b/pkg/cmd/project.go @@ -18,35 +18,40 @@ var projectsCreate = cli.Command{ Usage: "Create a new project.", Flags: []cli.Flag{ &jsonflag.JSONStringFlag{ - Name: "display-name", + Name: "display-name", + Usage: "Human-readable project name", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "display_name", }, }, &jsonflag.JSONStringFlag{ - Name: "org", + Name: "org", + Usage: "Organization name", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "org", }, }, &jsonflag.JSONStringFlag{ - Name: "slug", + Name: "slug", + Usage: "Project name/slug", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "slug", }, }, &jsonflag.JSONStringFlag{ - Name: "targets", + Name: "targets", + Usage: "Targets to generate for", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "targets.#", }, }, &jsonflag.JSONStringFlag{ - Name: "+target", + Name: "+target", + Usage: "Targets to generate for", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "targets.-1", @@ -93,18 +98,21 @@ var projectsList = cli.Command{ Usage: "List projects in an organization, from oldest to newest.", Flags: []cli.Flag{ &jsonflag.JSONStringFlag{ - Name: "cursor", + Name: "cursor", + Usage: "Pagination cursor from a previous response", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "cursor", }, }, &jsonflag.JSONFloatFlag{ - Name: "limit", + Name: "limit", + Usage: "Maximum number of projects to return, defaults to 10 (maximum: 100).", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "limit", }, + Value: 10, }, &jsonflag.JSONStringFlag{ Name: "org", @@ -127,7 +135,7 @@ func handleProjectsCreate(ctx context.Context, cmd *cli.Command) error { params := stainless.ProjectNewParams{} var res []byte _, err := cc.client.Projects.New( - context.TODO(), + ctx, params, option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), @@ -154,7 +162,7 @@ func handleProjectsRetrieve(ctx context.Context, cmd *cli.Command) error { } var res []byte _, err := cc.client.Projects.Get( - context.TODO(), + ctx, params, option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), @@ -181,7 +189,7 @@ func handleProjectsUpdate(ctx context.Context, cmd *cli.Command) error { } var res []byte _, err := cc.client.Projects.Update( - context.TODO(), + ctx, params, option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), @@ -205,7 +213,7 @@ func handleProjectsList(ctx context.Context, cmd *cli.Command) error { params := stainless.ProjectListParams{} var res []byte _, err := cc.client.Projects.List( - context.TODO(), + ctx, params, option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), diff --git a/pkg/cmd/projectbranch.go b/pkg/cmd/projectbranch.go index a9b97e5..35e002a 100644 --- a/pkg/cmd/projectbranch.go +++ b/pkg/cmd/projectbranch.go @@ -21,26 +21,30 @@ var projectsBranchesCreate = cli.Command{ Name: "project", }, &jsonflag.JSONStringFlag{ - Name: "branch", + Name: "branch", + Usage: "Branch name", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "branch", }, }, &jsonflag.JSONStringFlag{ - Name: "branch-from", + Name: "branch-from", + Usage: "Branch or commit SHA to branch from", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "branch_from", }, }, &jsonflag.JSONBoolFlag{ - Name: "force", + Name: "force", + Usage: "Whether to throw an error if the branch already exists. Defaults to false.", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "force", SetValue: true, }, + Value: false, }, }, Action: handleProjectsBranchesCreate, @@ -70,18 +74,21 @@ var projectsBranchesList = cli.Command{ Name: "project", }, &jsonflag.JSONStringFlag{ - Name: "cursor", + Name: "cursor", + Usage: "Pagination cursor from a previous response", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "cursor", }, }, &jsonflag.JSONFloatFlag{ - Name: "limit", + Name: "limit", + Usage: "Maximum number of items to return, defaults to 10 (maximum: 100).", Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "limit", }, + Value: 10, }, }, Action: handleProjectsBranchesList, @@ -114,11 +121,13 @@ var projectsBranchesRebase = cli.Command{ Name: "branch", }, &jsonflag.JSONStringFlag{ - Name: "base", + Name: "base", + Usage: `The branch or commit SHA to rebase onto. Defaults to "main".`, Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "base", }, + Value: "main", }, }, Action: handleProjectsBranchesRebase, @@ -137,7 +146,7 @@ func handleProjectsBranchesCreate(ctx context.Context, cmd *cli.Command) error { } var res []byte _, err := cc.client.Projects.Branches.New( - context.TODO(), + ctx, params, option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), @@ -168,7 +177,7 @@ func handleProjectsBranchesRetrieve(ctx context.Context, cmd *cli.Command) error } var res []byte _, err := cc.client.Projects.Branches.Get( - context.TODO(), + ctx, cmd.Value("branch").(string), params, option.WithMiddleware(cc.AsMiddleware()), @@ -196,7 +205,7 @@ func handleProjectsBranchesList(ctx context.Context, cmd *cli.Command) error { } var res []byte _, err := cc.client.Projects.Branches.List( - context.TODO(), + ctx, params, option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), @@ -227,7 +236,7 @@ func handleProjectsBranchesDelete(ctx context.Context, cmd *cli.Command) error { } var res []byte _, err := cc.client.Projects.Branches.Delete( - context.TODO(), + ctx, cmd.Value("branch").(string), params, option.WithMiddleware(cc.AsMiddleware()), @@ -259,7 +268,7 @@ func handleProjectsBranchesRebase(ctx context.Context, cmd *cli.Command) error { } var res []byte _, err := cc.client.Projects.Branches.Rebase( - context.TODO(), + ctx, cmd.Value("branch").(string), params, option.WithMiddleware(cc.AsMiddleware()), diff --git a/pkg/cmd/projectconfig.go b/pkg/cmd/projectconfig.go index 14c3eb8..6570e0f 100644 --- a/pkg/cmd/projectconfig.go +++ b/pkg/cmd/projectconfig.go @@ -21,11 +21,13 @@ var projectsConfigsRetrieve = cli.Command{ Name: "project", }, &jsonflag.JSONStringFlag{ - Name: "branch", + Name: "branch", + Usage: `Branch name, defaults to "main".`, Config: jsonflag.JSONConfig{ Kind: jsonflag.Query, Path: "branch", }, + Value: "main", }, &jsonflag.JSONStringFlag{ Name: "include", @@ -47,18 +49,21 @@ var projectsConfigsGuess = cli.Command{ Name: "project", }, &jsonflag.JSONStringFlag{ - Name: "spec", + Name: "spec", + Usage: "OpenAPI spec", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "spec", }, }, &jsonflag.JSONStringFlag{ - Name: "branch", + Name: "branch", + Usage: "Branch name", Config: jsonflag.JSONConfig{ Kind: jsonflag.Body, Path: "branch", }, + Value: "main", }, }, Action: handleProjectsConfigsGuess, @@ -77,7 +82,7 @@ func handleProjectsConfigsRetrieve(ctx context.Context, cmd *cli.Command) error } var res []byte _, err := cc.client.Projects.Configs.Get( - context.TODO(), + ctx, params, option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), @@ -104,7 +109,7 @@ func handleProjectsConfigsGuess(ctx context.Context, cmd *cli.Command) error { } var res []byte _, err := cc.client.Projects.Configs.Guess( - context.TODO(), + ctx, params, option.WithMiddleware(cc.AsMiddleware()), option.WithResponseBodyInto(&res), diff --git a/pkg/cmd/spec.go b/pkg/cmd/spec.go new file mode 100644 index 0000000..a7237ed --- /dev/null +++ b/pkg/cmd/spec.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package cmd + +import ( + "context" + "fmt" + + "github.com/stainless-api/stainless-api-go" + "github.com/stainless-api/stainless-api-go/option" + "github.com/tidwall/gjson" + "github.com/urfave/cli/v3" +) + +var specRetrieveDecoratedSpec = cli.Command{ + Name: "retrieve-decorated-spec", + Usage: "Retrieve the decorated spec for a given application and project.", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "client-id", + }, + &cli.StringFlag{ + Name: "project-name", + }, + }, + Action: handleSpecRetrieveDecoratedSpec, + HideHelpCommand: true, +} + +func handleSpecRetrieveDecoratedSpec(ctx context.Context, cmd *cli.Command) error { + cc := getAPICommandContext(cmd) + unusedArgs := cmd.Args().Slice() + if !cmd.IsSet("project-name") && len(unusedArgs) > 0 { + cmd.Set("project-name", unusedArgs[0]) + unusedArgs = unusedArgs[1:] + } + if len(unusedArgs) > 0 { + return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) + } + params := stainless.SpecGetDecoratedSpecParams{} + if cmd.IsSet("client-id") { + params.ClientID = cmd.Value("client-id").(string) + } + var res []byte + _, err := cc.client.Spec.GetDecoratedSpec( + ctx, + cmd.Value("project-name").(string), + params, + option.WithMiddleware(cc.AsMiddleware()), + option.WithResponseBodyInto(&res), + ) + if err != nil { + return err + } + + json := gjson.Parse(string(res)) + format := cmd.Root().String("format") + transform := cmd.Root().String("transform") + return ShowJSON("spec retrieve-decorated-spec", json, format, transform) +} diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go index 25090a4..531de40 100644 --- a/pkg/cmd/version.go +++ b/pkg/cmd/version.go @@ -2,4 +2,4 @@ package cmd -const Version = "0.1.0-alpha.49" // x-release-please-version +const Version = "0.1.0-alpha.50" // x-release-please-version