add -no-value option

This commit is contained in:
knqyf263 2019-12-23 13:26:45 +02:00
parent 2970b1c912
commit 59a4e49fa4
2 changed files with 14 additions and 1 deletions

View File

@ -25,6 +25,7 @@ const DefaultDBOpenTimeout = time.Second
var AppArgs struct { var AppArgs struct {
DBOpenTimeout time.Duration DBOpenTimeout time.Duration
ReadOnly bool ReadOnly bool
NoValue bool
} }
func init() { func init() {
@ -63,6 +64,10 @@ func parseArgs() {
if val == "true" { if val == "true" {
AppArgs.ReadOnly = true AppArgs.ReadOnly = true
} }
case "-no-value":
if val == "true" {
AppArgs.NoValue = true
}
case "-help": case "-help":
printUsage(nil) printUsage(nil)
default: default:
@ -73,6 +78,8 @@ func parseArgs() {
switch parms[i] { switch parms[i] {
case "-readonly", "-ro": case "-readonly", "-ro":
AppArgs.ReadOnly = true AppArgs.ReadOnly = true
case "-no-value":
AppArgs.NoValue = true
case "-help": case "-help":
printUsage(nil) printUsage(nil)
default: default:
@ -89,6 +96,7 @@ func printUsage(err error) {
fmt.Fprintf(os.Stderr, "Usage: %s [OPTIONS] <filename(s)>\nOptions:\n", ProgramName) fmt.Fprintf(os.Stderr, "Usage: %s [OPTIONS] <filename(s)>\nOptions:\n", ProgramName)
fmt.Fprintf(os.Stderr, " -timeout=duration\n DB file open timeout (default 1s)\n") 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, " -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() { func main() {

View File

@ -684,7 +684,12 @@ func (screen *BrowserScreen) bucketToLines(bkt *BoltBucket, style Style) []Line
pfg, pbg = style.cursorFg, style.cursorBg pfg, pbg = style.cursorFg, style.cursorBg
} }
prPrefix := strings.Repeat(" ", len(bp.GetPath())*2) 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}) ret = append(ret, Line{pairString, pfg, pbg})
} }
} else { } else {