Add graph markdown and canvas outputs
This commit is contained in:
@@ -70,7 +70,7 @@ Usage:
|
||||
gsp trace <id> [--root .] [--depth 3] [--out trace.json]
|
||||
gsp flatten <id> [--root .] [--depth 3] [--include-type a,b] [--exclude-type a,b] [--out flattened.json]
|
||||
gsp pack <id> [--root .] [--depth 3] [--budget 12000] [--out context-pack.json]
|
||||
gsp graph [id] [--root .] [--depth 3] [--format json|mermaid] [--out graph.json]
|
||||
gsp graph [id] [--root .] [--depth 3] [--format json|mermaid|md|canvas] [--out graph.json]
|
||||
gsp stage-check --stage implement [--root .] [--out stage-report.json]
|
||||
`)
|
||||
}
|
||||
@@ -267,7 +267,7 @@ func runGraph(args []string) error {
|
||||
root := commonRoot(fs)
|
||||
out := commonOut(fs)
|
||||
depth := fs.Int("depth", 3, "maximum relation depth when id is provided; -1 means unlimited")
|
||||
format := fs.String("format", "json", "json or mermaid")
|
||||
format := fs.String("format", "json", "json, mermaid, md, or canvas")
|
||||
if err := fs.Parse(normalizeFlagArgs(args)); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -283,13 +283,22 @@ func runGraph(args []string) error {
|
||||
return err
|
||||
}
|
||||
graph := project.Graph(id, *depth)
|
||||
if *format == "mermaid" {
|
||||
switch *format {
|
||||
case "mermaid":
|
||||
return writeText(*out, graph.Mermaid())
|
||||
}
|
||||
if *format != "json" {
|
||||
case "md":
|
||||
return writeText(*out, graph.Markdown())
|
||||
case "canvas":
|
||||
data, err := graph.Canvas()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return writeBytes(*out, data)
|
||||
case "json":
|
||||
return writeJSON(*out, graph)
|
||||
default:
|
||||
return fmt.Errorf("unsupported graph format %q", *format)
|
||||
}
|
||||
return writeJSON(*out, graph)
|
||||
}
|
||||
|
||||
func runStageCheck(args []string) error {
|
||||
|
||||
Reference in New Issue
Block a user