Skip to content

Commit

Permalink
Add command to echo database version and file path
Browse files Browse the repository at this point in the history
Fixes #32 (PR #67).
  • Loading branch information
Toreno96 authored Dec 15, 2023
1 parent b310bbf commit 2ff3bdc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Initial release after the hackathon
Fixes all the critical bugs

Optionally:
- [ ] Add command to echo db version and path
- [x] Add command to echo db version and path

## 0.3.0

Expand Down
19 changes: 19 additions & 0 deletions onetimepass/otp.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,25 @@ def rename(ctx: click.Context, old_alias: str, new_alias: str):
raise ClickUsageError(f"Alias: {old_alias} does not exist")


@otp.command(help="Print the database filepath and (optionally) its version.")
@click.option(
"version",
"--version",
is_flag=True,
help="Include the database version in the output (requires the master key).",
)
@click.pass_context
def db(ctx: click.Context, version: bool):
keyring = ctx.obj["keyring_"]

if version:
db = get_decrypted_db(keyring)
data = get_db_data(db)
click.echo(f"{settings.DB_PATH} (version {data.version})")
else:
click.echo(settings.DB_PATH)


def main():
otp()

Expand Down

0 comments on commit 2ff3bdc

Please sign in to comment.