diff --git a/internal/cmd/domain/create/create.go b/internal/cmd/domain/create/create.go index 681277f..4cab493 100644 --- a/internal/cmd/domain/create/create.go +++ b/internal/cmd/domain/create/create.go @@ -109,6 +109,7 @@ func runCreateDomainInteractive(f *cmdutil.Factory, opts *Options) error { s.Start() available, _, err := f.ApiClient.CheckDomainAvailable(context.Background(), opts.domainName, opts.IsGenerated, project.Region.ID) if err != nil { + s.Stop() return err } s.Stop() @@ -125,6 +126,7 @@ func runCreateDomainInteractive(f *cmdutil.Factory, opts *Options) error { s.Start() existedDomains, err := f.ApiClient.ListDomains(context.Background(), opts.id, opts.environmentID) if err != nil { + s.Stop() return err } s.Stop() @@ -162,6 +164,10 @@ func runCreateDomainNonInteractive(f *cmdutil.Factory, opts *Options) error { return fmt.Errorf("--id or --name is required") } + if opts.domainName == "" { + return fmt.Errorf("--domain is required in non-interactive mode") + } + if opts.environmentID == "" { envID, err := util.ResolveEnvironmentIDByServiceID(f.ApiClient, opts.id) if err != nil { @@ -184,6 +190,7 @@ func runCreateDomainNonInteractive(f *cmdutil.Factory, opts *Options) error { } if err != nil { + s.Stop() return fmt.Errorf("add domain failed: %w", err) } s.Stop()