@@ -15,6 +15,7 @@ import (
1515 "github.com/pkg/browser"
1616 "github.com/stainless-api/stainless-api-cli/pkg/jsonflag"
1717 "github.com/stainless-api/stainless-api-go"
18+ "github.com/stainless-api/stainless-api-go/option"
1819 "github.com/urfave/cli/v3"
1920)
2021
@@ -104,12 +105,13 @@ func handleInit(ctx context.Context, cmd *cli.Command) error {
104105 if err == nil && found {
105106 title := fmt .Sprintf ("Existing workspace detected: %s (project: %s)" , existingConfig .ConfigPath , existingConfig .Project )
106107 overwrite , err := Confirm (cmd , "" , title , "Do you want to overwrite your existing workplace configuration?" , true )
107- if err != nil {
108+ if err != nil || ! overwrite {
108109 return err
109110 }
110- if ! overwrite {
111- return nil
111+ if err := os . Remove ( existingConfig . ConfigPath ); err != nil {
112+ return err
112113 }
114+ existingConfig = WorkspaceConfig {}
113115 }
114116
115117 orgs := fetchUserOrgs (cc .client , ctx )
@@ -279,19 +281,19 @@ func createProject(ctx context.Context, cmd *cli.Command, cc *apiCommandContext,
279281 info .Property ("targets" , fmt .Sprintf ("%v" , selectedTargets ))
280282
281283 slug := nameToSlug (projectName )
282- // _, err := cc.client.Projects.New(
283- // ctx,
284- // stainless.ProjectNewParams{
285- // DisplayName: projectName,
286- // Org: org,
287- // Slug: slug,
288- // Targets: selectedTargets,
289- // },
290- // option.WithMiddleware(cc.AsMiddleware()),
291- // )
292- // if err != nil {
293- // return "", nil, err
294- // }
284+ _ , err := cc .client .Projects .New (
285+ ctx ,
286+ stainless.ProjectNewParams {
287+ DisplayName : projectName ,
288+ Org : org ,
289+ Slug : slug ,
290+ Targets : selectedTargets ,
291+ },
292+ option .WithMiddleware (cc .AsMiddleware ()),
293+ )
294+ if err != nil {
295+ return "" , nil , err
296+ }
295297
296298 info .Success ("Project created successfully" )
297299
@@ -301,25 +303,30 @@ func createProject(ctx context.Context, cmd *cli.Command, cc *apiCommandContext,
301303func initializeWorkspace (ctx context.Context , cmd * cli.Command , cc * apiCommandContext , projectSlug string , targets []stainless.Target ) error {
302304 info := Info ("Initializing workspace..." )
303305
304- openAPISpec := cmd .String ("openapi-spec" )
305- if openAPISpec == "" {
306+ var openAPISpecPath string
307+ if cmd .IsSet ("openapi-spec" ) {
308+ fmt .Printf ("OAS Path: %s\n " , openAPISpecPath )
309+ openAPISpecPath = cmd .String ("openapi-spec" )
310+ } else {
306311 var err error
307- openAPISpec , err = chooseOpenAPISpecLocation ()
312+ openAPISpecPath , err = chooseOpenAPISpecLocation ()
308313 if err != nil {
309314 return err
310315 }
311316 }
312317
313- stainlessConfig := cmd .String ("stainless-config" )
314- if stainlessConfig == "" {
318+ var stainlessConfigPath string
319+ if cmd .IsSet ("stainless-config" ) {
320+ stainlessConfigPath = cmd .String ("stainless-config" )
321+ } else {
315322 var err error
316- stainlessConfig , err = chooseStainlessConfigLocation ()
323+ stainlessConfigPath , err = chooseStainlessConfigLocation ()
317324 if err != nil {
318325 return err
319326 }
320327 }
321328
322- config , err := NewWorkspaceConfig (projectSlug , openAPISpec , stainlessConfig )
329+ config , err := NewWorkspaceConfig (projectSlug , openAPISpecPath , stainlessConfigPath )
323330 if err != nil {
324331 info .Error ("Failed to create workspace config: %v" , err )
325332 return fmt .Errorf ("project created but workspace initialization failed: %v" , err )
0 commit comments