Skip to content

Commit

Permalink
refactor: operation -> query
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Jan 9, 2025
1 parent 59a3c55 commit acda5ad
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions internal/core/blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ type DaselValue = map[string]any

var blueprintEngines = []string{"tree-sitter", "dasel", "command"}

// A Query is a single query that we want to run against a document.
// A Step is a single query that we want to run against a document.
//
// The result of the query is optionally assigned the given scope.
type Query struct {
Scope string `yaml:"scope"`
Operation string `yaml:"operation"`
type Step struct {
Scope string `yaml:"scope"`
Query string `yaml:"query"`
}

// A Blueprint is a set of queries that we want to run against a document.
Expand All @@ -31,8 +31,8 @@ type Query struct {
// - `dasel`
// - `command`
type Blueprint struct {
Engine string `yaml:"engine"`
Steps []Query `yaml:"steps"`
Engine string `yaml:"engine"`
Steps []Step `yaml:"steps"`
}

// A ScopedValues is a value that has been assigned a scope.
Expand Down Expand Up @@ -77,7 +77,7 @@ func (b *Blueprint) Apply(f *File) ([]ScopedValues, error) {
}

for _, s := range b.Steps {
selected, verr := dasel.Select(value, s.Operation)
selected, verr := dasel.Select(value, s.Query)
if verr != nil {
return found, verr
}
Expand Down
2 changes: 1 addition & 1 deletion internal/lint/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func updateQueries(f *core.File, blueprints map[string]*core.Blueprint) ([]strin
} else if sec.Match(f.Path) {
found := []string{}
for _, query := range blueprint.Steps {
found = append(found, query.Operation)
found = append(found, query.Query)
}
return found, nil
}
Expand Down
6 changes: 3 additions & 3 deletions testdata/styles/config/blueprints/OpenAPI.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
engine: dasel
steps:
- scope: title
operation: info.title
- operation: info.description
- operation: servers.all().description
query: info.title
- query: info.description
- query: servers.all().description
2 changes: 1 addition & 1 deletion testdata/styles/config/blueprints/Python.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
engine: tree-sitter
steps:
- operation: (comment)+ @comment
- query: (comment)+ @comment
2 changes: 1 addition & 1 deletion testdata/styles/config/blueprints/Vale.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
engine: dasel
steps:
- operation: description
- query: description

0 comments on commit acda5ad

Please sign in to comment.