aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/shell/state.go
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2025-11-21 21:37:13 -0500
committerJP Appel <jeanpierre.appel01@gmail.com>2025-11-21 21:37:13 -0500
commit6e8bbf7c98cfff0d333c3d06e10a9c2c2a15fb85 (patch)
treecc5e4e768945b4801559e5eb261b5c63066dd1c3 /pkg/shell/state.go
parent1aad60b49a32b6bced95a251f266799c031ca83e (diff)
Add native support for document slicesHEADmain
Diffstat (limited to 'pkg/shell/state.go')
-rw-r--r--pkg/shell/state.go34
1 files changed, 27 insertions, 7 deletions
diff --git a/pkg/shell/state.go b/pkg/shell/state.go
index 5acdaf1..1eed62f 100644
--- a/pkg/shell/state.go
+++ b/pkg/shell/state.go
@@ -1,9 +1,11 @@
package shell
import (
+ "bytes"
"fmt"
"strings"
+ "github.com/jpappel/atlas/pkg/index"
"github.com/jpappel/atlas/pkg/query"
)
@@ -16,6 +18,7 @@ const (
VAL_TOKENS
VAL_CLAUSE
VAL_ARTIFACT
+ VAL_RESULTS
)
type Value struct {
@@ -39,6 +42,8 @@ func (t ValueType) String() string {
return "Clause"
case VAL_ARTIFACT:
return "Compilation Artifact"
+ case VAL_RESULTS:
+ return "Query Result"
default:
return "Unkown"
}
@@ -76,6 +81,18 @@ func (v Value) String() string {
panic("Corrupted Type (expected query.CompilationArtifact)")
}
return artifact.String()
+ case VAL_RESULTS:
+ results, ok := v.Val.([]*index.Document)
+ if !ok {
+ panic("Corrupted Type (expected []*index.Document)")
+ }
+
+ b := bytes.Buffer{}
+ yo := query.YamlOutput{}
+ if _, err := yo.OutputTo(&b, results); err != nil {
+ panic(err)
+ }
+ return b.String()
case VAL_INVALID:
return "Invalid"
}
@@ -88,21 +105,24 @@ func (s State) String() string {
for k, v := range s {
b.WriteString(k)
b.WriteByte(':')
+ b.WriteByte(' ')
switch v.Type {
case VAL_INVALID:
- b.WriteString(" Invalid")
+ b.WriteString("Invalid")
case VAL_INT:
- b.WriteString(" Integer")
+ b.WriteString("Integer")
case VAL_STRING:
- b.WriteString(" String")
+ b.WriteString("String")
case VAL_TOKENS:
- b.WriteString(" Tokens")
+ b.WriteString("Tokens")
case VAL_CLAUSE:
- b.WriteString(" Clause")
+ b.WriteString("Clause")
case VAL_ARTIFACT:
- b.WriteString(" Artifact")
+ b.WriteString("Artifact")
+ case VAL_RESULTS:
+ b.WriteString("Results")
default:
- fmt.Fprintf(&b, " Unknown (%d)", v.Val)
+ fmt.Fprintf(&b, "Unknown (%d)", v.Val)
}
b.WriteByte('\n')
}