mirror of
https://github.com/meshcore-dev/meshcore-cli.git
synced 2026-04-20 22:13:48 +00:00
add shortcuts to commands
This commit is contained in:
parent
cff6f5060f
commit
6210bebd30
1 changed files with 19 additions and 19 deletions
38
mccli.py
38
mccli.py
|
|
@ -534,7 +534,7 @@ async def next_cmd(mc, cmds):
|
||||||
case "set_time" :
|
case "set_time" :
|
||||||
argnum = 1
|
argnum = 1
|
||||||
print(await mc.set_time(cmds[1]))
|
print(await mc.set_time(cmds[1]))
|
||||||
case "get_bat" :
|
case "get_bat" | "b":
|
||||||
print(await mc.get_bat())
|
print(await mc.get_bat())
|
||||||
case "reboot" :
|
case "reboot" :
|
||||||
print(await mc.reboot())
|
print(await mc.reboot())
|
||||||
|
|
@ -546,70 +546,70 @@ async def next_cmd(mc, cmds):
|
||||||
await mc.ensure_contacts()
|
await mc.ensure_contacts()
|
||||||
print(await mc.send_msg(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])[0:6],
|
print(await mc.send_msg(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])[0:6],
|
||||||
cmds[2]))
|
cmds[2]))
|
||||||
case "msg" : # sends to a contact from name
|
case "msg" | "m" : # sends to a contact from name
|
||||||
argnum = 2
|
argnum = 2
|
||||||
await mc.ensure_contacts()
|
await mc.ensure_contacts()
|
||||||
print(await mc.send_msg(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])[0:6],
|
print(await mc.send_msg(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])[0:6],
|
||||||
cmds[2]))
|
cmds[2]))
|
||||||
case "cmd" :
|
case "cmd" | "c" :
|
||||||
argnum = 2
|
argnum = 2
|
||||||
await mc.ensure_contacts()
|
await mc.ensure_contacts()
|
||||||
print(await mc.send_cmd(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])[0:6],
|
print(await mc.send_cmd(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])[0:6],
|
||||||
cmds[2]))
|
cmds[2]))
|
||||||
case "login" :
|
case "login" | "l" :
|
||||||
argnum = 2
|
argnum = 2
|
||||||
await mc.ensure_contacts()
|
await mc.ensure_contacts()
|
||||||
print(await mc.send_login(bytes.fromhex(mc.contacts[cmds[1]]["public_key"]),
|
print(await mc.send_login(bytes.fromhex(mc.contacts[cmds[1]]["public_key"]),
|
||||||
cmds[2]))
|
cmds[2]))
|
||||||
case "wait_login":
|
case "wait_login" | "wl":
|
||||||
print(await mc.wait_login())
|
print(await mc.wait_login())
|
||||||
case "req_status" :
|
case "req_status" | "rs" :
|
||||||
argnum = 1
|
argnum = 1
|
||||||
await mc.ensure_contacts()
|
await mc.ensure_contacts()
|
||||||
print(await mc.send_statusreq(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])))
|
print(await mc.send_statusreq(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])))
|
||||||
case "wait_status" :
|
case "wait_status" | "ws" :
|
||||||
print(await mc.wait_status())
|
print(await mc.wait_status())
|
||||||
case "contacts" :
|
case "contacts" | "lc":
|
||||||
print(json.dumps(await mc.get_contacts(),indent=4))
|
print(json.dumps(await mc.get_contacts(),indent=4))
|
||||||
case "change_path":
|
case "change_path" | "cp":
|
||||||
argnum = 2
|
argnum = 2
|
||||||
await mc.ensure_contacts()
|
await mc.ensure_contacts()
|
||||||
await mc.set_out_path(mc.contacts[cmds[1]], cmds[2])
|
await mc.set_out_path(mc.contacts[cmds[1]], cmds[2])
|
||||||
print(await mc.update_contact(mc.contacts[cmds[1]]))
|
print(await mc.update_contact(mc.contacts[cmds[1]]))
|
||||||
case "reset_path":
|
case "reset_path" | "rp" :
|
||||||
argnum = 1
|
argnum = 1
|
||||||
await mc.ensure_contacts()
|
await mc.ensure_contacts()
|
||||||
print(await mc.reset_path(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])))
|
print(await mc.reset_path(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])))
|
||||||
await mc.get_contacts()
|
await mc.get_contacts()
|
||||||
case "share_contact":
|
case "share_contact" | "sc":
|
||||||
argnum = 1
|
argnum = 1
|
||||||
await mc.ensure_contacts()
|
await mc.ensure_contacts()
|
||||||
print(await mc.share_contact(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])))
|
print(await mc.share_contact(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])))
|
||||||
case "remove_contact":
|
case "remove_contact" | "cr":
|
||||||
argnum = 1
|
argnum = 1
|
||||||
await mc.ensure_contacts()
|
await mc.ensure_contacts()
|
||||||
print(await mc.remove_contact(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])))
|
print(await mc.remove_contact(bytes.fromhex(mc.contacts[cmds[1]]["public_key"])))
|
||||||
case "recv" :
|
case "recv" | "r" :
|
||||||
print(await mc.get_msg())
|
print(await mc.get_msg())
|
||||||
case "sync_msgs" :
|
case "sync_msgs" | "sm":
|
||||||
res=True
|
res=True
|
||||||
while res:
|
while res:
|
||||||
res = await mc.get_msg()
|
res = await mc.get_msg()
|
||||||
print (res)
|
print (res)
|
||||||
case "wait_msg" :
|
case "wait_msg" | "wm" :
|
||||||
await mc.wait_msg()
|
await mc.wait_msg()
|
||||||
res = await mc.get_msg()
|
res = await mc.get_msg()
|
||||||
print (res)
|
print (res)
|
||||||
case "wait_ack" :
|
case "wait_ack" | "wa" :
|
||||||
await mc.wait_ack()
|
await mc.wait_ack()
|
||||||
case "infos" :
|
case "infos" | "i" :
|
||||||
print(json.dumps(mc.self_info,indent=4))
|
print(json.dumps(mc.self_info,indent=4))
|
||||||
case "advert" :
|
case "advert" | "a":
|
||||||
print(await mc.send_advert())
|
print(await mc.send_advert())
|
||||||
case "set_name" :
|
case "set_name" :
|
||||||
argnum = 1
|
argnum = 1
|
||||||
print(await mc.set_name(cmds[1]))
|
print(await mc.set_name(cmds[1]))
|
||||||
case "sleep" :
|
case "sleep" | "s" :
|
||||||
argnum = 1
|
argnum = 1
|
||||||
await asyncio.sleep(int(cmds[1]))
|
await asyncio.sleep(int(cmds[1]))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue