mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-30 13:56:37 -04:00
Enable entry password aging (sync with latest libmutton development version)
This commit is contained in:
+20
-3
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/rwinkhart/go-boilerplate/back"
|
||||
"github.com/rwinkhart/go-boilerplate/other"
|
||||
"github.com/rwinkhart/libmutton/age"
|
||||
"github.com/rwinkhart/libmutton/synccommon"
|
||||
)
|
||||
|
||||
@@ -47,7 +48,7 @@ func determineIndentation(skippedDirList []bool, dirList []string, currentDirInd
|
||||
}
|
||||
|
||||
// printFileEntry handles processing for printing file entries (determines color, wraps lines, and prints).
|
||||
func printFileEntry(entry string, lastSlash, charCounter, indent int, colorAlternator int8) (int, int8) {
|
||||
func printFileEntry(entry string, lastSlash, charCounter, indent int, colorAlternator int8, agingTimestamp int64) (int, int8) {
|
||||
// determine color to print fileEntryName (alternate each time function is run)
|
||||
var colorCode string
|
||||
if colorAlternator > 0 {
|
||||
@@ -57,6 +58,17 @@ func printFileEntry(entry string, lastSlash, charCounter, indent int, colorAlter
|
||||
}
|
||||
colorAlternator = -colorAlternator
|
||||
|
||||
// determine password aging dot
|
||||
var agingDot string
|
||||
switch age.TranslateAgeTimestamp(agingTimestamp) {
|
||||
case 1:
|
||||
agingDot = back.AnsiGreen + "⁍" + back.AnsiReset
|
||||
case 2:
|
||||
agingDot = back.AnsiWarning + "⁍" + back.AnsiReset
|
||||
case 3:
|
||||
agingDot = back.AnsiError + "⁍" + back.AnsiReset
|
||||
}
|
||||
|
||||
// trim the containing directory from the entry to determine fileEntryName
|
||||
fileEntryName := entry[lastSlash:]
|
||||
|
||||
@@ -72,7 +84,7 @@ func printFileEntry(entry string, lastSlash, charCounter, indent int, colorAlter
|
||||
}
|
||||
|
||||
// print fileEntryName to screen
|
||||
fmt.Printf("%s%s%s ", colorCode, fileEntryName, back.AnsiReset)
|
||||
fmt.Printf("%s%s%s%s ", agingDot, colorCode, fileEntryName, back.AnsiReset)
|
||||
|
||||
return charCounter, colorAlternator
|
||||
}
|
||||
@@ -83,6 +95,11 @@ func EntryListGen() {
|
||||
if err != nil {
|
||||
other.PrintError("Failed to generate entry list: "+err.Error(), back.ErrorRead)
|
||||
}
|
||||
var vanityPathsToTimestamps map[string]int64
|
||||
vanityPathsToTimestamps, err = synccommon.GetEntryAges()
|
||||
if err != nil {
|
||||
other.PrintError("Failed to retrieve entry aging data: "+err.Error(), back.ErrorRead)
|
||||
}
|
||||
|
||||
// print header bar w/total entry count
|
||||
fmt.Print("\n"+ansiBlackOnWhite, len(fileList), " libmutton entries:"+back.AnsiReset)
|
||||
@@ -134,7 +151,7 @@ func EntryListGen() {
|
||||
fmt.Printf("\n\n"+strings.Repeat(" ", indent*2)+ansiDirectoryHeader+"%s/"+back.AnsiReset+"\n", vanityDirectory)
|
||||
}
|
||||
|
||||
charCounter, colorAlternator = printFileEntry(file, lastSlash, charCounter, indent, colorAlternator)
|
||||
charCounter, colorAlternator = printFileEntry(file, lastSlash, charCounter, indent, colorAlternator, vanityPathsToTimestamps[file])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user