aboutsummaryrefslogtreecommitdiffstats
path: root/query/parser.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-03-22 13:53:34 +0100
committerMichael Muré <batolettre@gmail.com>2020-03-28 17:13:28 +0100
commit314fcbb2293d869c33d6a76aedd148aedff6561d (patch)
tree05386ddf08d7e1c2947a6fc6cf2fbd44efa19eaf /query/parser.go
parent5e4dc87ffec7f87bbf3ebfcf256777ad773e8450 (diff)
downloadgit-bug-314fcbb2293d869c33d6a76aedd148aedff6561d.tar.gz
query: no need for an ast package
Diffstat (limited to 'query/parser.go')
-rw-r--r--query/parser.go35
1 files changed, 17 insertions, 18 deletions
diff --git a/query/parser.go b/query/parser.go
index 89893b60..a379f750 100644
--- a/query/parser.go
+++ b/query/parser.go
@@ -4,7 +4,6 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/bug"
- "github.com/MichaelMure/git-bug/query/ast"
)
// Parse parse a query DSL
@@ -12,15 +11,15 @@ import (
// Ex: "status:open author:descartes sort:edit-asc"
//
// Supported filter qualifiers and syntax are described in docs/queries.md
-func Parse(query string) (*ast.Query, error) {
+func Parse(query string) (*Query, error) {
tokens, err := tokenize(query)
if err != nil {
return nil, err
}
- q := &ast.Query{
- OrderBy: ast.OrderByCreation,
- OrderDirection: ast.OrderDescending,
+ q := &Query{
+ OrderBy: OrderByCreation,
+ OrderDirection: OrderDescending,
}
sortingDone := false
@@ -66,31 +65,31 @@ func Parse(query string) (*ast.Query, error) {
return q, nil
}
-func parseSorting(q *ast.Query, value string) error {
+func parseSorting(q *Query, value string) error {
switch value {
// default ASC
case "id-desc":
- q.OrderBy = ast.OrderById
- q.OrderDirection = ast.OrderDescending
+ q.OrderBy = OrderById
+ q.OrderDirection = OrderDescending
case "id", "id-asc":
- q.OrderBy = ast.OrderById
- q.OrderDirection = ast.OrderAscending
+ q.OrderBy = OrderById
+ q.OrderDirection = OrderAscending
// default DESC
case "creation", "creation-desc":
- q.OrderBy = ast.OrderByCreation
- q.OrderDirection = ast.OrderDescending
+ q.OrderBy = OrderByCreation
+ q.OrderDirection = OrderDescending
case "creation-asc":
- q.OrderBy = ast.OrderByCreation
- q.OrderDirection = ast.OrderAscending
+ q.OrderBy = OrderByCreation
+ q.OrderDirection = OrderAscending
// default DESC
case "edit", "edit-desc":
- q.OrderBy = ast.OrderByEdit
- q.OrderDirection = ast.OrderDescending
+ q.OrderBy = OrderByEdit
+ q.OrderDirection = OrderDescending
case "edit-asc":
- q.OrderBy = ast.OrderByEdit
- q.OrderDirection = ast.OrderAscending
+ q.OrderBy = OrderByEdit
+ q.OrderDirection = OrderAscending
default:
return fmt.Errorf("unknown sorting %s", value)