From 59a4e49fa49cd0e6e864b365c922a9b3173a2813 Mon Sep 17 00:00:00 2001 From: knqyf263 Date: Mon, 23 Dec 2019 13:26:45 +0200 Subject: [PATCH] add -no-value option --- main.go | 8 ++++++++ screen_browser.go | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 0ad828e..885007c 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,7 @@ const DefaultDBOpenTimeout = time.Second var AppArgs struct { DBOpenTimeout time.Duration ReadOnly bool + NoValue bool } func init() { @@ -63,6 +64,10 @@ func parseArgs() { if val == "true" { AppArgs.ReadOnly = true } + case "-no-value": + if val == "true" { + AppArgs.NoValue = true + } case "-help": printUsage(nil) default: @@ -73,6 +78,8 @@ func parseArgs() { switch parms[i] { case "-readonly", "-ro": AppArgs.ReadOnly = true + case "-no-value": + AppArgs.NoValue = true case "-help": printUsage(nil) default: @@ -89,6 +96,7 @@ func printUsage(err error) { fmt.Fprintf(os.Stderr, "Usage: %s [OPTIONS] \nOptions:\n", ProgramName) fmt.Fprintf(os.Stderr, " -timeout=duration\n DB file open timeout (default 1s)\n") fmt.Fprintf(os.Stderr, " -ro, -readonly \n Open the DB in read-only mode\n") + fmt.Fprintf(os.Stderr, " -no-value \n Do not display a value in left pane\n") } func main() { diff --git a/screen_browser.go b/screen_browser.go index 19333ae..8676739 100644 --- a/screen_browser.go +++ b/screen_browser.go @@ -684,7 +684,12 @@ func (screen *BrowserScreen) bucketToLines(bkt *BoltBucket, style Style) []Line pfg, pbg = style.cursorFg, style.cursorBg } prPrefix := strings.Repeat(" ", len(bp.GetPath())*2) - pairString := fmt.Sprintf("%s%s: %s", prPrefix, stringify([]byte(bp.key)), stringify([]byte(bp.val))) + var pairString string + if AppArgs.NoValue { + pairString = fmt.Sprintf("%s%s", prPrefix, stringify([]byte(bp.key))) + } else { + pairString = fmt.Sprintf("%s%s: %s", prPrefix, stringify([]byte(bp.key)), stringify([]byte(bp.val))) + } ret = append(ret, Line{pairString, pfg, pbg}) } } else {