Skip to content

Commit

Permalink
Merge pull request #92 from adbenitez/issue-91
Browse files Browse the repository at this point in the history
add import subcommand
  • Loading branch information
adbenitez authored Oct 24, 2024
2 parents a09dacd + 40e4171 commit 6bc9ce7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions deltachat_cursed/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def __init__(self) -> None:
init_parser.add_argument("addr", help="your e-mail address")
init_parser.add_argument("password", help="your password")

import_parser = self.add_subcommand(import_cmd, name="import")
import_parser.add_argument("path", help="path to the backup file to import")

config_parser = self.add_subcommand(config_cmd, name="config")
config_parser.add_argument("option", help="option name", nargs="?")
config_parser.add_argument("value", help="option value to set", nargs="?")
Expand Down Expand Up @@ -93,6 +96,20 @@ def init_cmd(client: Client, args: Namespace) -> None:
sys.exit(1)


def import_cmd(client: Client, args: Namespace) -> None:
"""import account from backup file"""
if args.account:
print("Error: -a/--account can't be used with this subcommand")
sys.exit(1)

try:
client.rpc.import_backup(client.rpc.add_account(), args.path, None)
print("Backup imported successfully.")
except JsonRpcError as err:
print("ERROR: Failed to import backup:", err)
sys.exit(1)


def config_cmd(client: Client, args: Namespace) -> None:
"""set or get account configuration values"""
accounts = client.rpc.get_all_account_ids()
Expand Down

0 comments on commit 6bc9ce7

Please sign in to comment.