add -no-value option
This commit is contained in:
parent
2970b1c912
commit
59a4e49fa4
8
main.go
8
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] <filename(s)>\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() {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user