commit 56f096d5a2edad3f7ed52f23b25f48ad626387a7
parent f3d66162f58b052d7204966b8dbc7997947a03b7
Author: Sean Enck <sean@ttypty.com>
Date: Fri, 29 Jul 2022 18:32:44 -0400
remove shortcut args
Diffstat:
6 files changed, 23 insertions(+), 30 deletions(-)
diff --git a/README.md b/README.md
@@ -36,8 +36,7 @@ LOCKBOX_NOCLIP="yes"
Copy entries to clipboard
```
-lb -c my/secret/password
-# or lb clip
+lb clip my/secret/password
```
### insert
@@ -80,7 +79,7 @@ lb totp token
The token can be automatically copied to the clipboard too
```
-lb totp -c token
+lb totp -clip token
```
## git integration
diff --git a/cmd/lb/main.go b/cmd/lb/main.go
@@ -103,7 +103,7 @@ func main() {
os.Remove(entry)
hooks.Run(hooks.Remove, hooks.PostStep)
}
- case "show", "-c", "clip", "dump":
+ case "show", "clip", "dump":
fs := store.NewFileSystemStore()
opts := subcommands.DisplayOptions{Dump: command == "dump", Show: command == "show", Glob: getEntry(fs, []string{"***"}, 0), Store: fs}
opts.Show = opts.Show || opts.Dump
diff --git a/contrib/completions.bash b/contrib/completions.bash
@@ -1,7 +1,7 @@
# bash completion for lb -*- shell-script -*-
_is_clip() {
- if [ "$1" == "-c" ] || [ "$1" == "${2}clip" ]; then
+ if [ "$1" == "${2}clip" ]; then
echo 1
else
echo 0
@@ -10,7 +10,7 @@ _is_clip() {
_lb() {
local cur opts clip_enabled needs
- clip_enabled=" -c clip"
+ clip_enabled=" clip"
if [ -n "$LOCKBOX_NOCLIP" ]; then
if [ "$LOCKBOX_NOCLIP" == "yes" ]; then
clip_enabled=""
@@ -28,15 +28,15 @@ _lb() {
opts="-yes $(lb ls)"
;;
"insert")
- opts="-m -multi $(lb ls)"
+ opts="-multi $(lb ls)"
;;
"totp")
opts="-once -short "$(lb totp -ls)
if [ -n "$clip_enabled" ]; then
- opts="$opts -c -clip"
+ opts="$opts -clip"
fi
;;
- "-c" | "show" | "rm" | "clip")
+ "show" | "rm" | "clip")
opts=$(lb ls)
if [ $(_is_clip "${COMP_WORDS[1]}" "") == 1 ]; then
if [ -z "$clip_enabled" ]; then
@@ -49,10 +49,10 @@ _lb() {
if [ "$COMP_CWORD" -eq 3 ]; then
case "${COMP_WORDS[1]}" in
"insert")
- if [ "${COMP_WORDS[2]}" == "-m" ] || [ "${COMP_WORDS[2]}" == "-multi" ]; then
+ if [ "${COMP_WORDS[2]}" == "-multi" ]; then
opts=$(lb ls)
else
- opts="-m -multi"
+ opts="-multi"
fi
;;
"totp")
diff --git a/internal/cli/args.go b/internal/cli/args.go
@@ -15,11 +15,11 @@ type (
// ParseArgs parses CLI arguments.
func ParseArgs(arg string) Arguments {
args := Arguments{}
- args.Clip = arg == "-clip" || arg == "-c"
+ args.Clip = arg == "-clip"
args.Once = arg == "-once"
args.Short = arg == "-short"
- args.List = arg == "-ls" || arg == "-list"
- args.Multi = arg == "-m" || arg == "-multi"
+ args.List = arg == "-list"
+ args.Multi = arg == "-multi"
args.Yes = arg == "-yes"
return args
}
diff --git a/internal/cli/args_test.go b/internal/cli/args_test.go
@@ -5,29 +5,23 @@ import (
)
func TestClipArg(t *testing.T) {
- for _, check := range []string{"-c", "-clip"} {
- options := ParseArgs(check)
- if !options.Clip {
- t.Error("clip should be set")
- }
+ options := ParseArgs("-clip")
+ if !options.Clip {
+ t.Error("clip should be set")
}
}
func TestMultiArg(t *testing.T) {
- for _, check := range []string{"-m", "-multi"} {
- options := ParseArgs(check)
- if !options.Multi {
- t.Error("multi should be set")
- }
+ options := ParseArgs("-multi")
+ if !options.Multi {
+ t.Error("multi should be set")
}
}
func TestListArg(t *testing.T) {
- for _, check := range []string{"-list", "-ls"} {
- options := ParseArgs(check)
- if !options.List {
- t.Error("list should be set")
- }
+ options := ParseArgs("-list")
+ if !options.List {
+ t.Error("list should be set")
}
}
diff --git a/tests/run.sh b/tests/run.sh
@@ -43,7 +43,7 @@ _run() {
"$BIN/lb" show keys2/three
echo "y" | "$BIN/lb" dump keys2/three
echo "5ae472abqdekjqykoyxk7hvc2leklq5n" | "$BIN/lb" insert test/totp
- "$BIN/lb-totp" -ls
+ "$BIN/lb-totp" -list
"$BIN/lb-totp" test | tr '[:digit:]' 'X'
"$BIN/lb-gitdiff" bin/lb/keys/one.lb bin/lb/keys/one2.lb
yes 2>/dev/null | "$BIN/lb" rm keys2/three