aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-11-03 19:30:21 +0100
committerMatěj Cepl <mcepl@cepl.eu>2024-11-03 19:37:53 +0100
commit1793138a1b943e71a180dc6aa360b4599f97ebdd (patch)
tree3134a8f76342ba2262e4909e650e8192f270efea
parent0f629c91e14aebd675c22602d93e60860158d842 (diff)
downloadgit-bug-1793138a1b943e71a180dc6aa360b4599f97ebdd.tar.gz
fix[WIP]: more updatesbug-export
-rw-r--r--commands/export.go47
-rw-r--r--commands/root.go22
2 files changed, 45 insertions, 24 deletions
diff --git a/commands/export.go b/commands/export.go
index cd24b59a..aacad1e5 100644
--- a/commands/export.go
+++ b/commands/export.go
@@ -1,20 +1,31 @@
package commands
import (
+ "strings"
"encoding/json"
"github.com/spf13/cobra"
"github.com/git-bug/git-bug/entities/bug"
"github.com/git-bug/git-bug/entity"
+ "github.com/git-bug/git-bug/commands/execenv"
+ "github.com/git-bug/git-bug/query"
)
type exportOptions struct {
- queryOptions
+ actorQuery []string
+ authorQuery []string
+ labelQuery []string
+ noQuery []string
+ participantQuery []string
+ queryOptions []string
+ statusQuery []string
+ titleQuery []string
+ sortBy string
+ sortDirection string
}
-func newExportCommand() *cobra.Command {
- env := newEnv()
+func newExportCommand(env *execenv.Env) *cobra.Command {
options := exportOptions{}
cmd := &cobra.Command{
@@ -26,11 +37,10 @@ The output format is NDJSON (Newline delimited JSON).
You can pass an additional query to filter and order the list. This query can be expressed either with a simple query language, flags, a natural language full text search, or a combination of the aforementioned.`,
Example: `See ls`,
- PreRunE: loadBackend(env),
- PostRunE: closeBackend(env),
- RunE: func(cmd *cobra.Command, args []string) error {
+ PreRunE: execenv.LoadBackend(env),
+ PostRunE: execenv.CloseBackend(env, func(cmd *cobra.Command, args []string) error {
return runExport(env, options, args)
- },
+ }),
}
flags := cmd.Flags()
@@ -58,18 +68,29 @@ You can pass an additional query to filter and order the list. This query can be
return cmd
}
-func runExport(env *Env, opts exportOptions, args []string) error {
- q, err := makeQuery(args, &opts.queryOptions)
+func runExport(env *execenv.Env, opts exportOptions, args []string) error {
+ var q *query.Query
+ var err error
+
+ if len(args) >= 1 {
+ q, err = query.Parse(strings.Join(args, " "))
+ if err != nil {
+ return err
+ }
+ } else {
+ q = query.NewQuery()
+ }
+
+ // FIXME we are throwing away opts!
+ allIds, err := env.Backend.Bugs().Query(q)
if err != nil {
return err
}
- allIds := env.backend.QueryBugs(q)
-
- out := json.NewEncoder(env.out)
+ out := json.NewEncoder(env.Out)
for _, id := range allIds {
- b, err := env.backend.ResolveBug(id)
+ b, err := env.Backend.Bugs().Resolve(id)
if err != nil {
return err
}
diff --git a/commands/root.go b/commands/root.go
index 3cda27b5..6712da29 100644
--- a/commands/root.go
+++ b/commands/root.go
@@ -80,18 +80,18 @@ the same git remote you are already using to collaborate with other people.
cmd.AddCommand(newWipeCommand(env))
// Added with export NDJSON
- cmd.AddCommand(newAddCommand(env))
- cmd.AddCommand(newCommentCommand(env))
- cmd.AddCommand(newDeselectCommand(env))
+ // undefined cmd.AddCommand(newAddCommand(env))
+ // undefined cmd.AddCommand(newCommentCommand(env))
+ // undefined cmd.AddCommand(newDeselectCommand(env))
cmd.AddCommand(newExportCommand(env))
- cmd.AddCommand(newLsCommand(env))
- cmd.AddCommand(newLsIdCommand(env))
- cmd.AddCommand(newLsLabelCommand(env))
- cmd.AddCommand(newRmCommand(env))
- cmd.AddCommand(newSelectCommand(env))
- cmd.AddCommand(newShowCommand(env))
- cmd.AddCommand(newStatusCommand(env))
- cmd.AddCommand(newTitleCommand(env))
+ // undefined cmd.AddCommand(newLsCommand(env))
+ // undefined cmd.AddCommand(newLsIdCommand(env))
+ // undefined cmd.AddCommand(newLsLabelCommand(env))
+ // undefined cmd.AddCommand(newRmCommand(env))
+ // undefined cmd.AddCommand(newSelectCommand(env))
+ // undefined cmd.AddCommand(newShowCommand(env))
+ // undefined cmd.AddCommand(newStatusCommand(env))
+ // undefined cmd.AddCommand(newTitleCommand(env))
return cmd
}