Add strict custom field registry
This commit is contained in:
@@ -42,6 +42,8 @@ func run(args []string) error {
|
||||
return runValidate(args[1:])
|
||||
case "index":
|
||||
return runIndex(args[1:])
|
||||
case "fields":
|
||||
return runFields(args[1:])
|
||||
case "trace":
|
||||
return runTrace(args[1:])
|
||||
case "flatten":
|
||||
@@ -77,6 +79,7 @@ Usage:
|
||||
gsp completion install powershell
|
||||
gsp validate [--root .] [--out report.json]
|
||||
gsp index [--root .] [--out index.json]
|
||||
gsp fields list|validate [--root .] [--out fields.json]
|
||||
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]
|
||||
@@ -88,6 +91,53 @@ Usage:
|
||||
`)
|
||||
}
|
||||
|
||||
func runFields(args []string) error {
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("fields requires list or validate")
|
||||
}
|
||||
switch args[0] {
|
||||
case "list":
|
||||
return runFieldsList(args[1:])
|
||||
case "validate":
|
||||
return runFieldsValidate(args[1:])
|
||||
default:
|
||||
return fmt.Errorf("unknown fields command %q", args[0])
|
||||
}
|
||||
}
|
||||
|
||||
func runFieldsList(args []string) error {
|
||||
fs := flag.NewFlagSet("fields list", flag.ContinueOnError)
|
||||
root := commonRoot(fs)
|
||||
out := commonOut(fs)
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
project, err := gsp.LoadProject(*root)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if project.Fields == nil {
|
||||
return writeJSON(*out, map[string]any{"gspFieldsVersion": gsp.FieldsVersion, "fields": map[string]any{}})
|
||||
}
|
||||
return writeJSON(*out, project.Fields)
|
||||
}
|
||||
|
||||
func runFieldsValidate(args []string) error {
|
||||
fs := flag.NewFlagSet("fields validate", flag.ContinueOnError)
|
||||
root := commonRoot(fs)
|
||||
out := commonOut(fs)
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
project, err := gsp.LoadProject(*root)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
report := gsp.Report{OK: true}
|
||||
project.ValidateFieldRegistryOnly(&report)
|
||||
return writeReport(*out, report)
|
||||
}
|
||||
|
||||
func runLinks(args []string) error {
|
||||
fs := flag.NewFlagSet("links", flag.ContinueOnError)
|
||||
root := commonRoot(fs)
|
||||
|
||||
Reference in New Issue
Block a user