From 26a4a32a75c0aa9f1800638a055b0100fa1c8ba0 Mon Sep 17 00:00:00 2001 From: Jon Anderson Date: Sun, 5 Nov 2023 14:21:59 -0800 Subject: [PATCH] Moved flags into app package. (#191) --- internal/app/app.go | 10 +++++----- internal/app/{flag => }/flag.go | 6 ++---- main.go | 22 ++++++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) rename internal/app/{flag => }/flag.go (93%) diff --git a/internal/app/app.go b/internal/app/app.go index b264bf9c..fbb05be3 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -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" @@ -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, @@ -97,6 +96,7 @@ var Fdbq = &cobra.Command{ } return app.Run(cmd.Context()) } + app := headless.App{ Engine: eg, Format: fmt, diff --git a/internal/app/flag/flag.go b/internal/app/flag.go similarity index 93% rename from internal/app/flag/flag.go rename to internal/app/flag.go index ab225db4..7355b08b 100644 --- a/internal/app/flag/flag.go +++ b/internal/app/flag.go @@ -1,6 +1,4 @@ -package flag - -// TODO: Move flags into `internal/app` package. +package app import ( "encoding/binary" @@ -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") diff --git a/main.go b/main.go index 341c991f..74d45257 100644 --- a/main.go +++ b/main.go @@ -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) } }