formatSchemaOutput produces a text header + JSON body (same pattern as query_database).
(output *SchemaOutput, include string, warnings []string)
| 661 | |
| 662 | // formatSchemaOutput produces a text header + JSON body (same pattern as query_database). |
| 663 | func formatSchemaOutput(output *SchemaOutput, include string, warnings []string) string { |
| 664 | var sb strings.Builder |
| 665 | |
| 666 | for _, w := range warnings { |
| 667 | fmt.Fprintf(&sb, "Note: %s\n", w) |
| 668 | } |
| 669 | |
| 670 | fmt.Fprintf(&sb, "Database: %s (%s)\n", output.Database, output.Engine) |
| 671 | |
| 672 | if output.Table != nil { |
| 673 | writeTableHeader(&sb, output.Table) |
| 674 | } else { |
| 675 | writeSchemasHeader(&sb, output.Schemas, include) |
| 676 | } |
| 677 | |
| 678 | sb.WriteString("\n") |
| 679 | jsonBytes, _ := json.Marshal(output) |
| 680 | sb.Write(jsonBytes) |
| 681 | |
| 682 | return sb.String() |
| 683 | } |
| 684 | |
| 685 | // writeTableHeader writes the single-table header line. |
| 686 | func writeTableHeader(sb *strings.Builder, t *TableDetail) { |
no test coverage detected