Enhance API output formatting in start command
- Update the output for API and OpenAPI endpoints in `cmd/start.go` to conditionally display the correct URL based on the OpenAPI server status. - Remove redundant OpenAPI mode information display when the OpenAPI server is enabled, streamlining the API list output.
This commit is contained in:
parent
6c51e74b02
commit
71eab0689e
1 changed files with 14 additions and 8 deletions
22
cmd/start.go
22
cmd/start.go
|
|
@ -187,12 +187,20 @@ var startCmd = &cobra.Command{
|
|||
fmt.Println(color.WhiteString("\n---------------------------------"))
|
||||
fmt.Println(color.WhiteString(L("Access Points")))
|
||||
fmt.Println(color.WhiteString("---------------------------------"))
|
||||
apiRoot := "/api"
|
||||
if openapi.Server != nil {
|
||||
apiRoot = openapi.Server.Config.BaseURL
|
||||
}
|
||||
for _, endpoint := range endpoints {
|
||||
fmt.Println(color.CyanString("\n%s", endpoint.Interface))
|
||||
fmt.Println(color.WhiteString("--------------------------"))
|
||||
fmt.Println(color.WhiteString(L("Website")), color.GreenString(" %s", endpoint.URL))
|
||||
fmt.Println(color.WhiteString(L("Dashboard")), color.GreenString(" %s/%s/auth/entry", endpoint.URL, strings.Trim(root, "/")))
|
||||
fmt.Println(color.WhiteString(L("API")), color.GreenString(" %s/api", endpoint.URL))
|
||||
if openapi.Server != nil {
|
||||
fmt.Println(color.WhiteString(L("OpenAPI")), color.GreenString(" %s%s", endpoint.URL, apiRoot))
|
||||
} else {
|
||||
fmt.Println(color.WhiteString(L("API")), color.GreenString(" %s%s", endpoint.URL, apiRoot))
|
||||
}
|
||||
}
|
||||
fmt.Println("")
|
||||
|
||||
|
|
@ -454,17 +462,15 @@ func printApis(silent bool) {
|
|||
return
|
||||
}
|
||||
|
||||
// Skip detailed API list when OpenAPI is enabled
|
||||
if openapi.Server != nil {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(color.WhiteString("\n---------------------------------"))
|
||||
fmt.Println(color.WhiteString(L("APIs List")))
|
||||
fmt.Println(color.WhiteString("---------------------------------"))
|
||||
|
||||
// Show OpenAPI mode info if enabled
|
||||
if openapi.Server != nil {
|
||||
fmt.Println(color.CyanString("\nOpenAPI Mode: %s", apiRoot))
|
||||
fmt.Println(color.WhiteString("Developer APIs: %s/api/*", apiRoot))
|
||||
fmt.Println(color.WhiteString("Widgets: %s/__yao/*", apiRoot))
|
||||
}
|
||||
|
||||
for _, api := range api.APIs { // API info
|
||||
if len(api.HTTP.Paths) <= 0 {
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue