Skip to content

Commit

Permalink
Moved flags into app package. (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
janderland authored Nov 5, 2023
1 parent 14ad550 commit 26a4a32
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/janderland/fdbq/engine"
"github.com/janderland/fdbq/engine/facade"
"github.com/janderland/fdbq/internal/app/flag"
"github.com/janderland/fdbq/internal/app/fullscreen"
"github.com/janderland/fdbq/internal/app/headless"
"github.com/janderland/fdbq/parser/format"
Expand All @@ -29,15 +28,15 @@ var (
// and defines the API version FDB uses.
APIVersion = 620

flags *flag.Flags
flags *Flags
)

func init() {
flags = flag.SetupFlags(Fdbq)
flags = SetupFlags(FDBQ)
}

var Fdbq = &cobra.Command{
Use: "fdbq [flags]",
var FDBQ = &cobra.Command{
Use: "fdbq [flags] query ...",
Short: "fdbq is a query language for Foundation DB",
Version: Version,

Expand Down Expand Up @@ -97,6 +96,7 @@ var Fdbq = &cobra.Command{
}
return app.Run(cmd.Context())
}

app := headless.App{
Engine: eg,
Format: fmt,
Expand Down
6 changes: 2 additions & 4 deletions internal/app/flag/flag.go → internal/app/flag.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package flag

// TODO: Move flags into `internal/app` package.
package app

import (
"encoding/binary"
Expand Down Expand Up @@ -30,7 +28,7 @@ func SetupFlags(cmd *cobra.Command) *Flags {

cmd.Flags().StringVarP(&flags.Cluster, "cluster", "c", "", "path to cluster file")
cmd.Flags().BoolVarP(&flags.Write, "write", "w", false, "allow write queries")
cmd.Flags().BoolVar(&flags.Log, "log", false, "perform debug logging")
cmd.Flags().BoolVar(&flags.Log, "log", false, "enable debug logging")
cmd.Flags().StringVar(&flags.LogFile, "log-file", "log.txt", "logging file when in fullscreen")

cmd.Flags().StringArrayVarP(&flags.Queries, "query", "q", nil, "execute query non-interactively")
Expand Down
22 changes: 12 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ Usage:
Flags:
-b, --bytes print full byte strings instead of just their length
-c, --cluster string path to cluster file
-h, --help help for fdbq
--limit int limit the number of KVs read in range-reads
-l, --little encode/decode values as little endian instead of big endian
--log perform debug logging
-r, --reverse query range-reads in reverse order
-s, --strict throw an error if a KV is read which doesn't match the schema
-w, --write allow write queries
-b, --bytes print full byte strings instead of just their length
-c, --cluster string path to cluster file
-h, --help help for fdbq
--limit int limit the number of KVs read in range-reads
-l, --little encode/decode values as little endian instead of big endian
--log enable debug logging
--log-file string logging file when in fullscreen (default "log.txt")
-q, --query stringArray execute query non-interactively
-r, --reverse query range-reads in reverse order
-s, --strict throw an error if a KV is read which doesn't match the schema
-w, --write allow write queries
*/
package main

import "github.com/janderland/fdbq/internal/app"

func main() {
if err := app.Fdbq.Execute(); err != nil {
if err := app.FDBQ.Execute(); err != nil {
panic(err)
}
}

0 comments on commit 26a4a32

Please sign in to comment.