lockbox

password manager
Log | Files | Refs | README | LICENSE

commit 4621884e95ad9aa32753edf5b3d57642fe3230a7
parent 47df6990207e344efbf5971c79a5900dc1be24fd
Author: Sean Enck <sean@ttypty.com>
Date:   Mon, 27 Mar 2023 21:33:35 -0400

rename short -> minimal

Diffstat:
Minternal/cli/core.go | 8++++----
Minternal/inputs/env.go | 5+++--
Minternal/totp/core.go | 10+++++-----
Minternal/totp/core_test.go | 8++++----
Mtests/expected.log | 2++
Mtests/run.sh | 2++
6 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/internal/cli/core.go b/internal/cli/core.go @@ -47,8 +47,8 @@ const ( EnvCommand = "env" // TOTPClipCommand is the argument for copying totp codes to clipboard TOTPClipCommand = ClipCommand - // TOTPShortCommand is the argument for getting the short version of a code - TOTPShortCommand = "short" + // TOTPMinimalCommand is the argument for getting the short version of a code + TOTPMinimalCommand = "minimal" // TOTPListCommand will list the totp-enabled entries TOTPListCommand = ListCommand // TOTPOnceCommand will perform like a normal totp request but not refresh @@ -136,7 +136,7 @@ func BashCompletions(defaults bool) ([]string, error) { Executable: name, InsertCommand: InsertCommand, RemoveCommand: RemoveCommand, - TOTPSubCommands: []string{TOTPShortCommand, TOTPOnceCommand, TOTPShowCommand}, + TOTPSubCommands: []string{TOTPMinimalCommand, TOTPOnceCommand, TOTPShowCommand}, TOTPListCommand: TOTPListCommand, ClipCommand: ClipCommand, ShowCommand: ShowCommand, @@ -224,7 +224,7 @@ func Usage(verbose bool) ([]string, error) { results = append(results, subCommand(TOTPCommand, TOTPInsertCommand, "entry", "insert a new totp entry into the store")) results = append(results, subCommand(TOTPCommand, TOTPListCommand, "", "list entries with totp settings")) results = append(results, subCommand(TOTPCommand, TOTPOnceCommand, "entry", "display the first generated code")) - results = append(results, subCommand(TOTPCommand, TOTPShortCommand, "entry", "display the first generated code (no details)")) + results = append(results, subCommand(TOTPCommand, TOTPMinimalCommand, "entry", "display the first generated code (no details)")) results = append(results, subCommand(TOTPCommand, TOTPShowCommand, "entry", "show the totp entry")) results = append(results, command(VersionCommand, "", "display version information")) sort.Strings(results) diff --git a/internal/inputs/env.go b/internal/inputs/env.go @@ -67,8 +67,9 @@ const ( // ModTimeEnv is modtime override ability for entries ModTimeEnv = prefixKey + "SET_MODTIME" // ModTimeFormat is the expected modtime format - ModTimeFormat = time.RFC3339 - reKeySuffix = "_NEW" + ModTimeFormat = time.RFC3339 + reKeySuffix = "_NEW" + // MaxTOTPTimeDefault is the max TOTP time to run (default) MaxTOTPTimeDefault = "120" ) diff --git a/internal/totp/core.go b/internal/totp/core.go @@ -56,8 +56,8 @@ const ( ShowMode // ClipMode will copy to clipboard ClipMode - // ShortMode will display minimal information to display the token - ShortMode + // MinimalMode will display minimal information to display the token + MinimalMode // ListMode lists the available tokens ListMode // OnceMode will only show the token once and exit @@ -81,7 +81,7 @@ func (args *Arguments) display(opts Options) error { if err != nil { return err } - if args.Mode == ShortMode { + if args.Mode == MinimalMode { interactive = false } once := args.Mode == OnceMode @@ -252,8 +252,8 @@ func NewArguments(args []string, tokenType string) (*Arguments, error) { opts.Mode = ShowMode case cli.TOTPClipCommand: opts.Mode = ClipMode - case cli.TOTPShortCommand: - opts.Mode = ShortMode + case cli.TOTPMinimalCommand: + opts.Mode = MinimalMode case cli.TOTPOnceCommand: opts.Mode = OnceMode default: diff --git a/internal/totp/core_test.go b/internal/totp/core_test.go @@ -99,8 +99,8 @@ func TestNewArguments(t *testing.T) { if args.Mode != totp.ClipMode || args.Entry != "test" { t.Error("invalid args") } - args, _ = totp.NewArguments([]string{"short", "test"}, "test") - if args.Mode != totp.ShortMode || args.Entry != "test" { + args, _ = totp.NewArguments([]string{"minimal", "test"}, "test") + if args.Mode != totp.MinimalMode || args.Entry != "test" { t.Error("invalid args") } args, _ = totp.NewArguments([]string{"once", "test"}, "test") @@ -180,9 +180,9 @@ func TestNonListError(t *testing.T) { } } -func TestShort(t *testing.T) { +func TestMinimal(t *testing.T) { setup(t) - args, _ := totp.NewArguments([]string{"short", "test/test3"}, "totp") + args, _ := totp.NewArguments([]string{"minimal", "test/test3"}, "totp") opts := testOptions() m := newMock(t) opts.App = m diff --git a/tests/expected.log b/tests/expected.log @@ -18,6 +18,8 @@ test4 modtime: XXXX-XX-XX test/k XXXXXX +XXXXXX +XXXXXX key/a/one: modtime: XXXX-XX-XX hash: ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff diff --git a/tests/run.sh b/tests/run.sh @@ -35,6 +35,8 @@ _execute() { echo 5ae472abqdekjqykoyxk7hvc2leklq5n |${LB_BINARY} totp insert test/k/totp ${LB_BINARY} totp ls ${LB_BINARY} totp show test/k + ${LB_BINARY} totp once test/k + ${LB_BINARY} totp minimal test/k ${LB_BINARY} hash "$LOCKBOX_STORE" echo y |${LB_BINARY} rm keys2/k/three echo