Skip to content

Commit 91ff95a

Browse files
author
Anand
committed
ref issue #21 - Addded printEntryMinimal
1 parent 61b95cc commit 91ff95a

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

utils.go

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func getOrCreateLocalConfig(app string) (error, *Settings) {
104104
}
105105

106106
configFile = filepath.Join(configPath, "config.json")
107-
// fmt.Printf("Config file, path => %s %s\n", configFile, configPath)
107+
// fmt.Printf("Config file, path => %s %s\n", configFile, configPath)
108108

109109
if _, err = os.Stat(configFile); err == nil {
110110
fh, err = os.Open(configFile)
@@ -121,7 +121,7 @@ func getOrCreateLocalConfig(app string) (error, *Settings) {
121121
}
122122

123123
} else {
124-
// fmt.Printf("Creating default configuration ...")
124+
// fmt.Printf("Creating default configuration ...")
125125
settings = Settings{"", "aes", true, true, false, configFile, "id,asc", "+", "default", "bgblack"}
126126

127127
if err = writeSettings(&settings, configFile); err == nil {
@@ -337,6 +337,42 @@ func printEntry(entry *Entry, delim bool) error {
337337

338338
}
339339

340+
// Print an entry to the console with minimal data
341+
func printEntryMinimal(entry *Entry, delim bool) error {
342+
343+
var err error
344+
var settings *Settings
345+
346+
err, settings = getOrCreateLocalConfig(APP)
347+
348+
if err != nil {
349+
fmt.Printf("Error parsing config - \"%s\"\n", err.Error())
350+
return err
351+
}
352+
353+
fmt.Printf("%s", getColor(strings.ToLower(settings.Color)))
354+
if strings.HasPrefix(settings.BgColor, "bg") {
355+
fmt.Printf("%s", getColor(strings.ToLower(settings.BgColor)))
356+
}
357+
358+
if delim {
359+
printDelim(settings.Delim, settings.Color)
360+
}
361+
362+
fmt.Printf("Title: %s\n", entry.Title)
363+
fmt.Printf("User: %s\n", entry.User)
364+
fmt.Printf("URL: %s\n", entry.Url)
365+
fmt.Printf("Modified: %s\n", entry.Timestamp.Format("2006-06-02 15:04:05"))
366+
367+
printDelim(settings.Delim, settings.Color)
368+
369+
// Reset
370+
fmt.Printf("%s", getColor("default"))
371+
372+
return nil
373+
374+
}
375+
340376
// Read user input and return entered value
341377
func readInput(reader *bufio.Reader, prompt string) string {
342378

@@ -397,7 +433,7 @@ func isActiveDatabaseEncryptedAndMaxKryptOn() (bool, string) {
397433

398434
// (Temporarily) enable showing of passwords
399435
func setShowPasswords() error {
400-
// fmt.Printf("Setting show passwords to true\n")
436+
// fmt.Printf("Setting show passwords to true\n")
401437
settingsRider.ShowPasswords = true
402438
return nil
403439
}

0 commit comments

Comments
 (0)