lockbox

password manager
Log | Files | Refs | README | LICENSE

commit 468fd7380db2f83537bd4adea8be2b161ca5ee11
parent 858ab64ecda4b45ec96f67728383cdb4959667ca
Author: Sean Enck <sean@ttypty.com>
Date:   Mon,  2 Jun 2025 21:39:27 -0400

this util is overkill

Diffstat:
Minternal/app/completions/core.go | 7++++---
Minternal/app/help/core.go | 2+-
Dinternal/util/readfile.go | 14--------------
Dinternal/util/readfile_test.go | 23-----------------------
4 files changed, 5 insertions(+), 41 deletions(-)

diff --git a/internal/app/completions/core.go b/internal/app/completions/core.go @@ -5,13 +5,13 @@ import ( "bytes" "embed" "fmt" + "path/filepath" "slices" "sort" "text/template" "git.sr.ht/~enckse/lockbox/internal/app/commands" "git.sr.ht/~enckse/lockbox/internal/config" - "git.sr.ht/~enckse/lockbox/internal/util" ) type ( @@ -134,11 +134,12 @@ func Generate(completionType, exe string) ([]string, error) { commands.TOTPClip: c.Conditionals.Not.CanClip, commands.TOTPInsert: c.Conditionals.Not.ReadOnly, }) - using, err := util.ReadDirFile("shell", fmt.Sprintf("%s.sh", completionType), shell) + + using, err := shell.ReadFile(filepath.Join("shell", fmt.Sprintf("%s.sh", completionType))) if err != nil { return nil, err } - s, err := templateScript(using, c) + s, err := templateScript(string(using), c) if err != nil { return nil, err } diff --git a/internal/app/help/core.go b/internal/app/help/core.go @@ -149,7 +149,7 @@ func Usage(verbose bool, exe string) ([]string, error) { } func processDoc(header, file string, doc Documentation) (string, error) { - b, err := util.ReadDirFile(docDir, file, docs) + b, err := docs.ReadFile(filepath.Join(docDir, file)) if err != nil { return "", err } diff --git a/internal/util/readfile.go b/internal/util/readfile.go @@ -1,14 +0,0 @@ -package util - -import ( - "path/filepath" -) - -// ReadDirFile will read a dir+file -func ReadDirFile(dir, file string, e interface{ ReadFile(string) ([]byte, error) }) (string, error) { - b, err := e.ReadFile(filepath.Join(dir, file)) - if err != nil { - return "", err - } - return string(b), err -} diff --git a/internal/util/readfile_test.go b/internal/util/readfile_test.go @@ -1,23 +0,0 @@ -package util_test - -import ( - "testing" - - "git.sr.ht/~enckse/lockbox/internal/util" -) - -type mockReadFile struct{} - -func (m mockReadFile) ReadFile(path string) ([]byte, error) { - return []byte(path), nil -} - -func TestReadEmbed(t *testing.T) { - read, err := util.ReadDirFile("xyz", "zzz", mockReadFile{}) - if err != nil { - t.Errorf("invalid error: %v", err) - } - if string(read) != "xyz/zzz" { - t.Errorf("invalid read: %s", string(read)) - } -}