lockbox

password manager
Log | Files | Refs | README | LICENSE

commit b239eb4efa41a1c7caa4f78b89f818c89f9c1e49
parent fb902c67b289238b9597dd1526238364e23119d7
Author: Sean Enck <sean@ttypty.com>
Date:   Fri, 26 Nov 2021 20:22:02 -0500

deprecate stats command

Diffstat:
Dcmd/lb-stats/main.go | 77-----------------------------------------------------------------------------
Mtests/expected.log | 8--------
Mtests/run.sh | 1-
3 files changed, 0 insertions(+), 86 deletions(-)

diff --git a/cmd/lb-stats/main.go b/cmd/lb-stats/main.go @@ -1,77 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "os" - "os/exec" - "path/filepath" - "strings" - - "voidedtech.com/lockbox/internal" - "voidedtech.com/stock" -) - -type ( - // History is commit information for the object. - History struct { - Hash string `json:"hash"` - Date string `json:"date"` - } - - // Stats are general entry stats. - Stats struct { - Entry string `json:"entry"` - Name string `json:"name"` - Dir string `json:"dir"` - History []History `json:"history"` - } -) - -func main() { - args := os.Args - store := internal.GetStore() - items, err := internal.Find(store, true) - if err != nil { - stock.Die("unable to find entries", err) - } - results := []Stats{} - for _, item := range items { - if len(args) > 1 { - if !strings.HasPrefix(item, args[1]) { - continue - } - } - stat := Stats{} - stat.Entry = item - stat.Name = filepath.Base(item) - stat.Dir = filepath.Dir(item) - cmd := exec.Command("git", "-C", store, "log", "--format=%h %aI", fmt.Sprintf("%s%s", item, internal.Extension)) - b, err := cmd.Output() - if err != nil { - stock.Die("failed to get git history", err) - } - history := []History{} - for _, value := range strings.Split(string(b), "\n") { - cleaned := strings.TrimSpace(value) - if len(cleaned) == 0 { - continue - } - parts := strings.Split(cleaned, " ") - if len(parts) != 2 { - stock.Die("invalid format entry", stock.NewBasicError("mismatch between format string and struct?")) - } - history = append(history, History{Hash: parts[0], Date: parts[1]}) - } - stat.History = history - results = append(results, stat) - } - if len(results) == 0 { - stock.Die("found no entries", stock.NewBasicError("no entries")) - } - j, err := json.MarshalIndent(results, "", " ") - if err != nil { - stock.Die("unable to prep json", err) - } - fmt.Println(string(j)) -} diff --git a/tests/expected.log b/tests/expected.log @@ -23,14 +23,6 @@ test4 test XXXXXX -[ - { - "entry": "keys/one2", - "name": "one2", - "dir": "keys", - "history": [] - } -] test2 remove entry? (y/N) remove entry? (y/N) diff --git a/tests/run.sh b/tests/run.sh @@ -42,7 +42,6 @@ _run() { echo "5ae472abqdekjqykoyxk7hvc2leklq5n" | "$BIN/lb" insert totp/test "$BIN/lb-totp" ls "$BIN/lb-totp" test | tr '[:digit:]' 'X' - "$BIN/lb-stats" keys/one2 "$BIN/lb-diff" bin/lb/keys/one.lb bin/lb/keys/one2.lb yes 2>/dev/null | "$BIN/lb" rm keys2/three echo