From d3a1fc60e3d95abc329378317fb1c8efbb52782c Mon Sep 17 00:00:00 2001 From: Leon Yang Date: Fri, 9 Dec 2022 15:25:10 +0800 Subject: [PATCH] Directly select the only one project (#51) If there is only one project, directly use the one in interactive mode. --- internal/service/cloud/logic.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/service/cloud/logic.go b/internal/service/cloud/logic.go index e8094282..f64128a8 100644 --- a/internal/service/cloud/logic.go +++ b/internal/service/cloud/logic.go @@ -51,6 +51,15 @@ func GetSelectedProject(pageSize int64, client TiDBCloudClient) (*Project, error if err != nil { return nil, err } + + // If there is only one project, return it directly. + if len(projectItems) == 1 { + return &Project{ + projectItems[0].ID, + projectItems[0].Name, + }, nil + } + set := hashset.New() for _, item := range projectItems { set.Add(&Project{