Add GSP links field and link inspection
This commit is contained in:
@@ -48,6 +48,8 @@ func run(args []string) error {
|
||||
return runFlatten(args[1:])
|
||||
case "pack":
|
||||
return runPack(args[1:])
|
||||
case "links":
|
||||
return runLinks(args[1:])
|
||||
case "impact":
|
||||
return runImpact(args[1:])
|
||||
case "message":
|
||||
@@ -78,6 +80,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 .] [--for implement] [--stage implement] [--depth 3] [--budget 12000] [--format json|md|canvas] [--out context-pack.json]
|
||||
gsp links <id> [--root .] [--depth -1] [--format json|md] [--out links.json]
|
||||
gsp impact <id> [--root .] [--depth -1] [--format json|md|canvas] [--out impact.json]
|
||||
gsp message validate <file> [--root .] [--out message-report.json]
|
||||
gsp graph [id] [--root .] [--depth 3] [--format json|mermaid|md|canvas] [--out graph.json]
|
||||
@@ -85,6 +88,33 @@ Usage:
|
||||
`)
|
||||
}
|
||||
|
||||
func runLinks(args []string) error {
|
||||
fs := flag.NewFlagSet("links", flag.ContinueOnError)
|
||||
root := commonRoot(fs)
|
||||
out := commonOut(fs)
|
||||
depth := fs.Int("depth", -1, "maximum relation depth; -1 means unlimited")
|
||||
format := fs.String("format", "json", "json or md")
|
||||
if err := fs.Parse(normalizeFlagArgs(args)); err != nil {
|
||||
return err
|
||||
}
|
||||
if fs.NArg() != 1 {
|
||||
return fmt.Errorf("links requires one GSP id")
|
||||
}
|
||||
project, err := gsp.LoadProject(*root)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result := project.Links(fs.Arg(0), *depth)
|
||||
switch *format {
|
||||
case "json":
|
||||
return writeJSON(*out, result)
|
||||
case "md":
|
||||
return writeText(*out, result.Markdown())
|
||||
default:
|
||||
return fmt.Errorf("unsupported links format %q", *format)
|
||||
}
|
||||
}
|
||||
|
||||
func runCompletion(args []string) error {
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("completion requires powershell, bash, zsh, fish, or install powershell")
|
||||
|
||||
Reference in New Issue
Block a user