From c356f5121ca6491fe2e3cc8f06131c12f86edfae Mon Sep 17 00:00:00 2001 From: Florent de Lamotte Date: Fri, 16 May 2025 10:00:20 +0200 Subject: [PATCH] import contact --- pyproject.toml | 4 ++-- src/meshcore_cli/meshcore_cli.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0f65aa2..2c1d56e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "meshcore-cli" -version = "0.8.0.dev4" +version = "0.8.0.dev5" authors = [ { name="Florent de Lamotte", email="florent@frizoncorrea.fr" }, ] @@ -17,7 +17,7 @@ classifiers = [ ] license = "MIT" license-files = ["LICEN[CS]E*"] -dependencies = [ "meshcore >= 1.9.8.dev3", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0" ] +dependencies = [ "meshcore >= 1.9.8.dev5", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0" ] [project.urls] Homepage = "https://github.com/fdlamotte/meshcore-cli" diff --git a/src/meshcore_cli/meshcore_cli.py b/src/meshcore_cli/meshcore_cli.py index fa8844c..8a5eaf4 100644 --- a/src/meshcore_cli/meshcore_cli.py +++ b/src/meshcore_cli/meshcore_cli.py @@ -239,6 +239,7 @@ def make_completion_dict(contacts, to=None): "reset_path" : contact_list, "change_path" : contact_list, "remove_contact" : contact_list, + "import_contact" : {"meshcore://":None}, "login" : contact_list, "cmd" : contact_list, "req_status" : contact_list, @@ -1240,6 +1241,16 @@ async def next_cmd(mc, cmds, json_output=False): else : print(res.payload['uri']) + case "import_contact"|"ic": + argnum = 1 + if cmds[1].startswith("meshcore://") : + res = await mc.commands.import_contact(bytes.fromhex(cmds[1][11:])) + logger.debug(res) + if res.type == EventType.ERROR: + print(f"Error while importing contact: {res}") + else: + logger.info("Contact successfully added, refresh with lc") + case "upload_contact" | "uc" : argnum = 1 await mc.ensure_contacts()