diff --git a/app.go b/app.go index e606dc5..7742f8e 100644 --- a/app.go +++ b/app.go @@ -60,6 +60,10 @@ WEBSITE: Aliases: []string{"c"}, Usage: "Select only items with given category", }, + &ucli.BoolFlag{ + Name: "noclip", + Usage: "Disable clipboard", + }, } // default command to get password diff --git a/pkg/action/default.go b/pkg/action/default.go index 78dab70..1dcdfbf 100644 --- a/pkg/action/default.go +++ b/pkg/action/default.go @@ -42,7 +42,7 @@ func (s *Action) Default(c *ucli.Context) error { return err } - if ctxutil.IsQuickSelect(ctx) { + if ctxutil.IsQuickSelect(ctx) && !ctxutil.IsNoClip(ctx) { // disable notifications for quick select if err = clipboard.CopyTo(ctxutil.WithNotifications(ctx, false), "", []byte(credential.Username)); err != nil { return ExitError(ExitIO, err, "failed to copy to clipboard: %s", err) @@ -60,18 +60,17 @@ func (s *Action) Default(c *ucli.Context) error { return err } - if ctxutil.IsAutoClip(ctx) { + if ctxutil.IsAutoClip(ctx) && !ctxutil.IsNoClip(ctx) { identifier := out.BuildIdentifier(name, credential.Username) if err = clipboard.CopyTo(ctx, identifier, []byte(credential.Password)); err != nil { return ExitError(ExitIO, err, "failed to copy to clipboard: %s", err) } - if ctxutil.IsAutoClip(ctx) && !c.Bool("print") { + if !c.Bool("print") { out.SuccessfulCopiedToClipboard(name, credential.Username) return nil } } out.DisplayCredential(credential) - out.SuccessfulCopiedToClipboard(name, credential.Username) return nil } diff --git a/pkg/cli/selection/selection_windows.go b/pkg/cli/selection/selection_windows.go index c439481..a466fdf 100644 --- a/pkg/cli/selection/selection_windows.go +++ b/pkg/cli/selection/selection_windows.go @@ -51,6 +51,14 @@ func Default(message string, items []string) (int, error) { case keys.Down: list.Next() update = true + case keys.RuneKey: + if key.String() == "j" { + list.Next() + update = true + } else if key.String() == "k" { + list.Prev() + update = true + } } if update { diff --git a/pkg/ctxutil/ctxutil.go b/pkg/ctxutil/ctxutil.go index 46615d9..18f4917 100644 --- a/pkg/ctxutil/ctxutil.go +++ b/pkg/ctxutil/ctxutil.go @@ -27,6 +27,7 @@ const ( ctxKeyQuickSelect ctxKeyCategory ctxKeyPhoneNumber + ctxNoClip ) // WithGlobalFlags parses any global flags from the cli context and returns @@ -39,6 +40,9 @@ func WithGlobalFlags(c *cli.Context) context.Context { if c.IsSet("category") { ctx = WithCategory(ctx, c.String("category")) } + if c.IsSet("noclip") { + ctx = WithNoClip(ctx, true) + } return ctx } @@ -350,3 +354,11 @@ func GetPhoneNumber(ctx context.Context) string { } return sv } + +func WithNoClip(ctx context.Context, value bool) context.Context { + return context.WithValue(ctx, ctxNoClip, value) +} + +func IsNoClip(ctx context.Context) bool { + return is(ctx, ctxNoClip, false) +}