keepassxc
keepassxc copied to clipboard
CLI - Allow setting format of `search` command output
Summary
In KeePass CLI's command search
- add an option to set the requested format of the response
This can be implemented as a new flag -f | --format
, the flag might support the following placeholders:
Placeholder | Data |
---|---|
{TITLE} |
The title of the records (currently shown in search command) |
{PATH} |
The path of folders for the records (currently shown in search command) |
{URL} |
The URL of the records (or empty string) |
{USERNAME} |
The username of the records |
{TOTP_STATUS} |
Either "Has TOTP" or "No TOTP" |
and the default should be {PATH}/{TITLE}
to keep backward compatibility
Another possible solution, might be to support the result in different formats such as JSON / YAML/CSV/Plain (default, backward compatible)
Examples
To list all search result with their username - run
Format version: $ keepassxc-cli search -f '{PATH} > {TITLE} [{USERNAME}]'
database.kdbx term
JSON: $ keepassxc-cli search -f 'json' database.kdbx term
Context
When creating an integration to KeePassXC using the CLI - it might require a search capability. currently when searching using the CLI, in order to show the (for example) the username of the search result records - one must execute a seperate show
command for each record in the search results - which might accumulate to 10s of requests per search - which is very inefficient, and slow
I encountered this issue when working on a contribution to the RayCast integration: https://www.raycast.com/zkytech/keepassxc