lockbox

password manager
Log | Files | Refs | README | LICENSE

commit b085278b69295fae8edf0ae93120f13e2bad196c
parent 9d1cc6884f85d5334d522eece9ffc239ebf116d4
Author: Sean Enck <sean@ttypty.com>
Date:   Sun, 15 Dec 2024 17:23:38 -0500

use constant exe name

Diffstat:
Minternal/app/commands/core.go | 2++
Minternal/app/info.go | 20++------------------
Minternal/platform/clip/core.go | 8++------
3 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/internal/app/commands/core.go b/internal/app/commands/core.go @@ -60,6 +60,8 @@ const ( CompletionsFish = "fish" // PasswordGenerate is the command to do password generation PasswordGenerate = "pwgen" + // Executable is the name of the executable + Executable = "lb" ) var ( diff --git a/internal/app/info.go b/internal/app/info.go @@ -30,14 +30,6 @@ func Info(w io.Writer, command string, args []string) (bool, error) { return false, nil } -func exeName() (string, error) { - exe, err := os.Executable() - if err != nil { - return "", err - } - return filepath.Base(exe), nil -} - func info(command string, args []string) ([]string, error) { switch command { case commands.Help: @@ -59,11 +51,7 @@ func info(command string, args []string) ([]string, error) { return nil, errors.New("invalid help option") } } - exe, err := exeName() - if err != nil { - return nil, err - } - results, err := help.Usage(isAdvanced, exe) + results, err := help.Usage(isAdvanced, commands.Executable) if err != nil { return nil, err } @@ -93,10 +81,6 @@ func info(command string, args []string) ([]string, error) { return results, nil case commands.Completions: shell := "" - exe, err := exeName() - if err != nil { - return nil, err - } switch len(args) { case 0: shell = filepath.Base(os.Getenv("SHELL")) @@ -108,7 +92,7 @@ func info(command string, args []string) ([]string, error) { if !slices.Contains(commands.CompletionTypes, shell) { return nil, fmt.Errorf("unknown completion type: %s", shell) } - return completions.Generate(shell, exe) + return completions.Generate(shell, commands.Executable) } return nil, nil } diff --git a/internal/platform/clip/core.go b/internal/platform/clip/core.go @@ -4,10 +4,10 @@ package clip import ( "errors" "fmt" - "os" "os/exec" osc "github.com/aymanbagabas/go-osc52" + "github.com/seanenck/lockbox/internal/app/commands" "github.com/seanenck/lockbox/internal/config" "github.com/seanenck/lockbox/internal/platform" ) @@ -88,11 +88,7 @@ func (c Board) CopyTo(value string) error { pipeTo(cmd, value, true, args...) if value != "" { fmt.Printf("clipboard will clear in %d seconds\n", c.MaxTime) - exe, err := os.Executable() - if err != nil { - return err - } - pipeTo(exe, value, false, "clear") + pipeTo(commands.Executable, value, false, "clear") } return nil }