mirror of
https://github.com/larksuite/cli.git
synced 2026-07-06 16:18:05 +08:00
43 lines
1.4 KiB
Go
43 lines
1.4 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
||
// SPDX-License-Identifier: MIT
|
||
|
||
package apps
|
||
|
||
import (
|
||
"fmt"
|
||
"strings"
|
||
|
||
"github.com/larksuite/cli/internal/validate"
|
||
)
|
||
|
||
// URL helpers for the db CLI commands.
|
||
|
||
// appTablesPath 返回 app db 表列表 URL(复用存量「获取数据表列表」接口)。
|
||
func appTablesPath(appID string) string {
|
||
return fmt.Sprintf("%s/apps/%s/tables", apiBasePath, validate.EncodePathSegment(appID))
|
||
}
|
||
|
||
// appTablePath 返回单个 app db 表详情 URL(复用存量「获取数据表详细信息」接口)。
|
||
func appTablePath(appID, table string) string {
|
||
return appTablesPath(appID) + "/" + validate.EncodePathSegment(table)
|
||
}
|
||
|
||
// appSQLPath 返回 app db SQL 执行 URL(复用存量「执行 SQL」接口)。
|
||
func appSQLPath(appID string) string {
|
||
return fmt.Sprintf("%s/apps/%s/sql_commands", apiBasePath, validate.EncodePathSegment(appID))
|
||
}
|
||
|
||
// appDbEnvCreatePath 返回 app db 环境创建 URL(服务端接口名仍为 db_dev_init)。
|
||
func appDbEnvCreatePath(appID string) string {
|
||
return fmt.Sprintf("%s/apps/%s/db_dev_init", apiBasePath, validate.EncodePathSegment(appID))
|
||
}
|
||
|
||
// requireAppID trims --app-id and rejects blank, returning a uniform validation error.
|
||
func requireAppID(raw string) (string, error) {
|
||
id := strings.TrimSpace(raw)
|
||
if id == "" {
|
||
return "", appsValidationParamError("--app-id", "--app-id is required")
|
||
}
|
||
return id, nil
|
||
}
|