mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 15:28:44 +00:00
Merge pull request #463 from PR0M3TH3AN/codex/update-cli-commands-to-sync-vault
Add vault sync to CLI entry commands
This commit is contained in:
@@ -150,6 +150,7 @@ def entry_add(
|
|||||||
pm = _get_pm(ctx)
|
pm = _get_pm(ctx)
|
||||||
index = pm.entry_manager.add_entry(label, length, username, url)
|
index = pm.entry_manager.add_entry(label, length, username, url)
|
||||||
typer.echo(str(index))
|
typer.echo(str(index))
|
||||||
|
pm.sync_vault()
|
||||||
|
|
||||||
|
|
||||||
@entry_app.command("add-totp")
|
@entry_app.command("add-totp")
|
||||||
@@ -172,6 +173,7 @@ def entry_add_totp(
|
|||||||
digits=digits,
|
digits=digits,
|
||||||
)
|
)
|
||||||
typer.echo(uri)
|
typer.echo(uri)
|
||||||
|
pm.sync_vault()
|
||||||
|
|
||||||
|
|
||||||
@entry_app.command("add-ssh")
|
@entry_app.command("add-ssh")
|
||||||
@@ -190,6 +192,7 @@ def entry_add_ssh(
|
|||||||
notes=notes,
|
notes=notes,
|
||||||
)
|
)
|
||||||
typer.echo(str(idx))
|
typer.echo(str(idx))
|
||||||
|
pm.sync_vault()
|
||||||
|
|
||||||
|
|
||||||
@entry_app.command("add-pgp")
|
@entry_app.command("add-pgp")
|
||||||
@@ -212,6 +215,7 @@ def entry_add_pgp(
|
|||||||
notes=notes,
|
notes=notes,
|
||||||
)
|
)
|
||||||
typer.echo(str(idx))
|
typer.echo(str(idx))
|
||||||
|
pm.sync_vault()
|
||||||
|
|
||||||
|
|
||||||
@entry_app.command("add-nostr")
|
@entry_app.command("add-nostr")
|
||||||
@@ -229,6 +233,7 @@ def entry_add_nostr(
|
|||||||
notes=notes,
|
notes=notes,
|
||||||
)
|
)
|
||||||
typer.echo(str(idx))
|
typer.echo(str(idx))
|
||||||
|
pm.sync_vault()
|
||||||
|
|
||||||
|
|
||||||
@entry_app.command("add-seed")
|
@entry_app.command("add-seed")
|
||||||
@@ -249,6 +254,7 @@ def entry_add_seed(
|
|||||||
notes=notes,
|
notes=notes,
|
||||||
)
|
)
|
||||||
typer.echo(str(idx))
|
typer.echo(str(idx))
|
||||||
|
pm.sync_vault()
|
||||||
|
|
||||||
|
|
||||||
@entry_app.command("add-key-value")
|
@entry_app.command("add-key-value")
|
||||||
@@ -262,6 +268,7 @@ def entry_add_key_value(
|
|||||||
pm = _get_pm(ctx)
|
pm = _get_pm(ctx)
|
||||||
idx = pm.entry_manager.add_key_value(label, value, notes=notes)
|
idx = pm.entry_manager.add_key_value(label, value, notes=notes)
|
||||||
typer.echo(str(idx))
|
typer.echo(str(idx))
|
||||||
|
pm.sync_vault()
|
||||||
|
|
||||||
|
|
||||||
@entry_app.command("add-managed-account")
|
@entry_app.command("add-managed-account")
|
||||||
@@ -280,6 +287,7 @@ def entry_add_managed_account(
|
|||||||
notes=notes,
|
notes=notes,
|
||||||
)
|
)
|
||||||
typer.echo(str(idx))
|
typer.echo(str(idx))
|
||||||
|
pm.sync_vault()
|
||||||
|
|
||||||
|
|
||||||
@entry_app.command("modify")
|
@entry_app.command("modify")
|
||||||
@@ -308,6 +316,7 @@ def entry_modify(
|
|||||||
digits=digits,
|
digits=digits,
|
||||||
value=value,
|
value=value,
|
||||||
)
|
)
|
||||||
|
pm.sync_vault()
|
||||||
|
|
||||||
|
|
||||||
@entry_app.command("archive")
|
@entry_app.command("archive")
|
||||||
@@ -316,6 +325,7 @@ def entry_archive(ctx: typer.Context, entry_id: int) -> None:
|
|||||||
pm = _get_pm(ctx)
|
pm = _get_pm(ctx)
|
||||||
pm.entry_manager.archive_entry(entry_id)
|
pm.entry_manager.archive_entry(entry_id)
|
||||||
typer.echo(str(entry_id))
|
typer.echo(str(entry_id))
|
||||||
|
pm.sync_vault()
|
||||||
|
|
||||||
|
|
||||||
@entry_app.command("unarchive")
|
@entry_app.command("unarchive")
|
||||||
@@ -324,6 +334,7 @@ def entry_unarchive(ctx: typer.Context, entry_id: int) -> None:
|
|||||||
pm = _get_pm(ctx)
|
pm = _get_pm(ctx)
|
||||||
pm.entry_manager.restore_entry(entry_id)
|
pm.entry_manager.restore_entry(entry_id)
|
||||||
typer.echo(str(entry_id))
|
typer.echo(str(entry_id))
|
||||||
|
pm.sync_vault()
|
||||||
|
|
||||||
|
|
||||||
@entry_app.command("totp-codes")
|
@entry_app.command("totp-codes")
|
||||||
|
@@ -103,6 +103,7 @@ def test_entry_add_commands(
|
|||||||
entry_manager=SimpleNamespace(**{method: func}),
|
entry_manager=SimpleNamespace(**{method: func}),
|
||||||
parent_seed="seed",
|
parent_seed="seed",
|
||||||
select_fingerprint=lambda fp: None,
|
select_fingerprint=lambda fp: None,
|
||||||
|
sync_vault=lambda: None,
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
||||||
result = runner.invoke(app, ["entry", command] + cli_args)
|
result = runner.invoke(app, ["entry", command] + cli_args)
|
||||||
|
@@ -332,6 +332,7 @@ def test_entry_add(monkeypatch):
|
|||||||
pm = SimpleNamespace(
|
pm = SimpleNamespace(
|
||||||
entry_manager=SimpleNamespace(add_entry=add_entry),
|
entry_manager=SimpleNamespace(add_entry=add_entry),
|
||||||
select_fingerprint=lambda fp: None,
|
select_fingerprint=lambda fp: None,
|
||||||
|
sync_vault=lambda: None,
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
||||||
result = runner.invoke(
|
result = runner.invoke(
|
||||||
@@ -362,6 +363,7 @@ def test_entry_modify(monkeypatch):
|
|||||||
pm = SimpleNamespace(
|
pm = SimpleNamespace(
|
||||||
entry_manager=SimpleNamespace(modify_entry=modify_entry),
|
entry_manager=SimpleNamespace(modify_entry=modify_entry),
|
||||||
select_fingerprint=lambda fp: None,
|
select_fingerprint=lambda fp: None,
|
||||||
|
sync_vault=lambda: None,
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
||||||
result = runner.invoke(app, ["entry", "modify", "1", "--username", "alice"])
|
result = runner.invoke(app, ["entry", "modify", "1", "--username", "alice"])
|
||||||
@@ -378,6 +380,7 @@ def test_entry_archive(monkeypatch):
|
|||||||
pm = SimpleNamespace(
|
pm = SimpleNamespace(
|
||||||
entry_manager=SimpleNamespace(archive_entry=archive_entry),
|
entry_manager=SimpleNamespace(archive_entry=archive_entry),
|
||||||
select_fingerprint=lambda fp: None,
|
select_fingerprint=lambda fp: None,
|
||||||
|
sync_vault=lambda: None,
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
||||||
result = runner.invoke(app, ["entry", "archive", "3"])
|
result = runner.invoke(app, ["entry", "archive", "3"])
|
||||||
@@ -395,6 +398,7 @@ def test_entry_unarchive(monkeypatch):
|
|||||||
pm = SimpleNamespace(
|
pm = SimpleNamespace(
|
||||||
entry_manager=SimpleNamespace(restore_entry=restore_entry),
|
entry_manager=SimpleNamespace(restore_entry=restore_entry),
|
||||||
select_fingerprint=lambda fp: None,
|
select_fingerprint=lambda fp: None,
|
||||||
|
sync_vault=lambda: None,
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
||||||
result = runner.invoke(app, ["entry", "unarchive", "4"])
|
result = runner.invoke(app, ["entry", "unarchive", "4"])
|
||||||
|
Reference in New Issue
Block a user