@@ -74,7 +74,6 @@ var initCommand = cli.Command{
7474 Value : true ,
7575 },
7676 },
77- Before : before ,
7877 Action : handleInit ,
7978 HideHelpCommand : true ,
8079}
@@ -149,7 +148,7 @@ func ensureExistingWorkspaceIsDeleted(cmd *cli.Command) error {
149148 title := fmt .Sprintf ("Existing workspace detected: %s (project: %s)" , existingConfig .ConfigPath , existingConfig .Project )
150149 overwrite , err := console .Confirm (cmd , "" , title , "Do you want to overwrite your existing workplace configuration?" , true )
151150 if err != nil || ! overwrite {
152- return err
151+ return huh . ErrUserAborted
153152 }
154153 if err := os .Remove (existingConfig .ConfigPath ); err != nil {
155154 return err
@@ -502,7 +501,7 @@ func askExistingOpenAPISpec(group console.Group) (content string, err error) {
502501 return "" , fmt .Errorf ("failed to read OpenAPI spec from %s: %w" , filePath , err )
503502 }
504503
505- group .Property ("openapi " , filePath )
504+ group .Property ("openapi_spec " , filePath )
506505
507506 return string (fileBytes ), nil
508507
@@ -614,17 +613,17 @@ func chooseStainlessConfigLocation(group console.Group) (string, error) {
614613}
615614
616615// downloadConfigFiles downloads the OpenAPI spec and Stainless config from the API
617- func downloadConfigFiles (ctx context.Context , client stainless.Client , config WorkspaceConfig ) error {
618- if config .StainlessConfig == "" {
616+ func downloadConfigFiles (ctx context.Context , client stainless.Client , wc WorkspaceConfig ) error {
617+ if wc .StainlessConfig == "" {
619618 return fmt .Errorf ("No destination for the stainless configuration file" )
620619 }
621- if config .OpenAPISpec == "" {
620+ if wc .OpenAPISpec == "" {
622621 return fmt .Errorf ("No destination for the OpenAPI spec file" )
623622 }
624623
625624 group := console .Info ("Downloading configuration files" )
626625 params := stainless.ProjectConfigGetParams {
627- Project : stainless .String (config .Project ),
626+ Project : stainless .String (wc .Project ),
628627 Include : stainless .String ("openapi" ),
629628 }
630629
@@ -678,7 +677,7 @@ func downloadConfigFiles(ctx context.Context, client stainless.Client, config Wo
678677 }
679678 }
680679
681- if err := writeFileWithConfirm (config .StainlessConfig , []byte (stainlessConfig ), "Stainless configuration" ); err != nil {
680+ if err := writeFileWithConfirm (Relative ( wc .StainlessConfig ) , []byte (stainlessConfig ), "Stainless configuration" ); err != nil {
682681 return err
683682 }
684683 }
@@ -694,7 +693,7 @@ func downloadConfigFiles(ctx context.Context, client stainless.Client, config Wo
694693 }
695694
696695 // TODO: we should warn or confirm if the downloaded file has a different file extension than the destination filename
697- if err := writeFileWithConfirm (config .OpenAPISpec , []byte (openAPISpec ), "OpenAPI spec" ); err != nil {
696+ if err := writeFileWithConfirm (Relative ( wc .OpenAPISpec ) , []byte (openAPISpec ), "OpenAPI spec" ); err != nil {
698697 return err
699698 }
700699 }
@@ -712,13 +711,9 @@ func configureTargets(slug string, targets []stainless.Target, config *Workspace
712711
713712 // Initialize target configs with default absolute paths
714713 targetConfigs := make (map [stainless.Target ]* TargetConfig , len (targets ))
715- cwd , err := os .Getwd ()
716- if err != nil {
717- return fmt .Errorf ("failed to get current directory: %w" , err )
718- }
719714 for _ , target := range targets {
720715 defaultPath := filepath .Join ("sdks" , fmt .Sprintf ("%s-%s" , slug , target ))
721- targetConfigs [target ] = & TargetConfig {OutputPath : Resolve ( cwd , defaultPath ) }
716+ targetConfigs [target ] = & TargetConfig {OutputPath : defaultPath }
722717 }
723718
724719 // Create form fields for each target
@@ -762,7 +757,7 @@ func configureTargets(slug string, targets []stainless.Target, config *Workspace
762757 }
763758
764759 for target , targetConfig := range targetConfigs {
765- group .Property (string (target )+ ".output_path" , targetConfig .OutputPath )
760+ group .Property (string (target )+ ".output_path" , Relative ( targetConfig .OutputPath ) )
766761 }
767762
768763 group .Success ("Targets configured to output locally" )
@@ -852,12 +847,7 @@ func getAvailableTargetInfo(ctx context.Context, client stainless.Client, projec
852847 return false
853848 }
854849 }
855- for _ , target := range buildObj .Languages () {
856- if target == item .Name {
857- return false
858- }
859- }
860- return true
850+ return ! slices .Contains (buildObj .Languages (), item .Name )
861851 })
862852}
863853
0 commit comments