Add --field name option to retrieve entry name
This commit is contained in:
parent
6d3e0e4190
commit
4d6e64668a
@ -72,7 +72,7 @@ Launches fzf in the terminal with fuzzy matching. Recently used entries appear a
|
|||||||
| Flag | Description | Default |
|
| Flag | Description | Default |
|
||||||
|--------------------------|--------------------------------------|------------|
|
|--------------------------|--------------------------------------|------------|
|
||||||
| `--selector rofi\|fzf` | Which selector UI to use | `rofi` |
|
| `--selector rofi\|fzf` | Which selector UI to use | `rofi` |
|
||||||
| `--field password\|username\|totp` | Which field to retrieve (fzf / history) | `password` |
|
| `--field password\|username\|totp\|name` | Which field to retrieve (fzf / history) | `password` |
|
||||||
| `--print` | Print to stdout instead of clipboard | off |
|
| `--print` | Print to stdout instead of clipboard | off |
|
||||||
|
|
||||||
The selected field is copied to the clipboard using `wl-copy` (Wayland) or `xclip` (X11). When `--print` is passed, the value is printed to stdout instead.
|
The selected field is copied to the clipboard using `wl-copy` (Wayland) or `xclip` (X11). When `--print` is passed, the value is printed to stdout instead.
|
||||||
|
|||||||
@ -13,7 +13,7 @@ def parse_args():
|
|||||||
select_parser = subparsers.add_parser("select")
|
select_parser = subparsers.add_parser("select")
|
||||||
select_parser.add_argument("--selector", default="rofi", choices=["rofi", "fzf"])
|
select_parser.add_argument("--selector", default="rofi", choices=["rofi", "fzf"])
|
||||||
select_parser.add_argument(
|
select_parser.add_argument(
|
||||||
"--field", default="password", choices=["username", "password", "totp"]
|
"--field", default="password", choices=["username", "password", "totp", "name"]
|
||||||
)
|
)
|
||||||
select_parser.add_argument("--print", dest="print_result", action="store_true")
|
select_parser.add_argument("--print", dest="print_result", action="store_true")
|
||||||
# rofi script-mode passes the selected title as a positional arg — accept and ignore it
|
# rofi script-mode passes the selected title as a positional arg — accept and ignore it
|
||||||
@ -28,7 +28,7 @@ def parse_args():
|
|||||||
get_parser = history_sub.add_parser("get")
|
get_parser = history_sub.add_parser("get")
|
||||||
get_parser.add_argument("index", type=int)
|
get_parser.add_argument("index", type=int)
|
||||||
get_parser.add_argument(
|
get_parser.add_argument(
|
||||||
"--field", default="password", choices=["username", "password", "totp"]
|
"--field", default="password", choices=["username", "password", "totp", "name"]
|
||||||
)
|
)
|
||||||
get_parser.add_argument("--print", dest="print_result", action="store_true")
|
get_parser.add_argument("--print", dest="print_result", action="store_true")
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ DEFAULT_KEYBINDINGS = {
|
|||||||
"username": "Control+Return",
|
"username": "Control+Return",
|
||||||
"totp": "Shift+Return",
|
"totp": "Shift+Return",
|
||||||
}
|
}
|
||||||
VALID_FIELDS = {"password", "username", "totp"}
|
VALID_FIELDS = {"password", "username", "totp", "name"}
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@ -33,6 +33,8 @@ def list_entries() -> list[Entry]:
|
|||||||
|
|
||||||
|
|
||||||
def get_field(entry: Entry, field: str) -> str:
|
def get_field(entry: Entry, field: str) -> str:
|
||||||
|
if field == "name":
|
||||||
|
return entry.name
|
||||||
if field == "totp":
|
if field == "totp":
|
||||||
return __get_totp(entry)
|
return __get_totp(entry)
|
||||||
if field == "username":
|
if field == "username":
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user