meshcore-cli 1.6.11__tar.gz → 1.6.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: meshcore-cli
3
- Version: 1.6.11
3
+ Version: 1.6.12
4
4
  Summary: Command line interface to meshcore companion radios and repeaters
5
5
  Project-URL: Homepage, https://github.com/fdlamotte/meshcore-cli
6
6
  Project-URL: Issues, https://github.com/fdlamotte/meshcore-cli/issues
@@ -113,6 +113,9 @@ Commands are given after arguments, they can be chained and some have shortcuts.
113
113
  aliases_load : load aliases from a file
114
114
  handler_attach <d> <c> : attach c as a handler for d (rxlog|msgs|chan_data|telemetry)
115
115
  handler_detach <n> : detach an handler (from its handle n)
116
+ timer <s> <c> : runs command c every s seconds
117
+ timer_cancel <n> : cancels a timer (from its handle n)
118
+ timers : lists current timers
116
119
  Messaging
117
120
  msg <name> <msg> : send message to node by name m {
118
121
  wait_ack : wait an ack wa }
@@ -248,6 +251,18 @@ handler_attach rxlog cat
248
251
 
249
252
  Will print out the content of `rx_log` as it comes in.
250
253
 
254
+ #### Timers
255
+
256
+ `timer [-j] [-c<contact>] [-s<scope>] <s> <line>` runs `line` every `s` seconds.
257
+
258
+ - `-c` sets the contact the line is run from (`~` for root).
259
+ - `-s` sets the scope for the line (default is the current scope of the node).
260
+ - `-j` forces json output for the timed line.
261
+
262
+ `timers` lists the running timers and `timer_cancel <n>` cancels timer `n`.
263
+
264
+ From the command line, timers only run while a command is waiting, so end the command list with `sleep <s>` or `wk` (`meshcli timer 60 "chan 1 hi" sleep 3600`). In chat mode, a `sleep` or `wk` holds up timers until it returns.
265
+
251
266
  ### Contact management
252
267
 
253
268
  To receive a message from another user, it is necessary to have its public key. This key is stored on a contact list in the device, and this list has a finite size (50 when meshcore started, now over 350 for most devices).
@@ -95,6 +95,9 @@ Commands are given after arguments, they can be chained and some have shortcuts.
95
95
  aliases_load : load aliases from a file
96
96
  handler_attach &lt;d&gt; &lt;c&gt; : attach c as a handler for d (rxlog|msgs|chan_data|telemetry)
97
97
  handler_detach &lt;n&gt; : detach an handler (from its handle n)
98
+ timer &lt;s&gt; &lt;c&gt; : runs command c every s seconds
99
+ timer_cancel &lt;n&gt; : cancels a timer (from its handle n)
100
+ timers : lists current timers
98
101
  Messaging
99
102
  msg &lt;name&gt; &lt;msg&gt; : send message to node by name m {
100
103
  wait_ack : wait an ack wa }
@@ -230,6 +233,18 @@ handler_attach rxlog cat
230
233
 
231
234
  Will print out the content of `rx_log` as it comes in.
232
235
 
236
+ #### Timers
237
+
238
+ `timer [-j] [-c<contact>] [-s<scope>] <s> <line>` runs `line` every `s` seconds.
239
+
240
+ - `-c` sets the contact the line is run from (`~` for root).
241
+ - `-s` sets the scope for the line (default is the current scope of the node).
242
+ - `-j` forces json output for the timed line.
243
+
244
+ `timers` lists the running timers and `timer_cancel <n>` cancels timer `n`.
245
+
246
+ From the command line, timers only run while a command is waiting, so end the command list with `sleep <s>` or `wk` (`meshcli timer 60 "chan 1 hi" sleep 3600`). In chat mode, a `sleep` or `wk` holds up timers until it returns.
247
+
233
248
  ### Contact management
234
249
 
235
250
  To receive a message from another user, it is necessary to have its public key. This key is stored on a contact list in the device, and this list has a finite size (50 when meshcore started, now over 350 for most devices).
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "meshcore-cli"
7
- version = "1.6.11"
7
+ version = "1.6.12"
8
8
  authors = [
9
9
  { name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
10
10
  ]
@@ -35,7 +35,7 @@ except ImportError:
35
35
  from meshcore import MeshCore, EventType, logger
36
36
 
37
37
  # Version
38
- VERSION = "v1.6.11"
38
+ VERSION = "v1.6.12"
39
39
 
40
40
  # default ble address is stored in a config file
41
41
  MCCLI_CONFIG_DIR = os.path.expanduser("~/.config/meshcore/")
@@ -123,6 +123,11 @@ HANDLERS = { # dicts that will be indexed by numbers
123
123
  LAST_HANDLER_ID = 0
124
124
  HANDLER_QUEUE_SIZE = 100
125
125
 
126
+ # Timers for repeating commands
127
+ TIMERS = {}
128
+ LAST_TIMER_ID = 0
129
+ CMD_LOCK = asyncio.Lock()
130
+
126
131
  # is the companion supposed to have cli
127
132
  HAS_CLI_CMD = False
128
133
 
@@ -157,6 +162,15 @@ LC_SORT_ORDER = ""
157
162
 
158
163
  LAST_DISCOVERED_NODES = []
159
164
 
165
+ def parse_duration(s, unit="s"):
166
+ mult = {"s": 1, "m": 60, "h": 3600, "d": 86400}
167
+ s = str(s).strip()
168
+ if s and s[-1] in mult:
169
+ unit = s[-1]
170
+ s = s[:-1]
171
+ secs = float(s) * mult[unit]
172
+ return secs
173
+
160
174
  def time_ago_from_timestamp (timestamp):
161
175
  if timestamp == 0:
162
176
  return "0"
@@ -228,6 +242,23 @@ def enqueue_handler_event(handler_type, payload):
228
242
  except asyncio.QueueFull:
229
243
  logger.warning(f"Handler {handler['id']} queue is full; dropping event")
230
244
 
245
+ async def run_timer(mc, timer):
246
+ while True:
247
+ await asyncio.sleep(timer["secs"])
248
+ async with CMD_LOCK:
249
+ base = set_scope.current_scope
250
+ if base is None:
251
+ base = ""
252
+ try:
253
+ if timer["scope"] != base:
254
+ await set_scope(mc, timer["scope"])
255
+ await process_redirected_line(mc, timer["cmd"], timer["contact"], timer["scope"], None, base, json_output=timer["json"], sink=sys.stdout)
256
+ except Exception as e:
257
+ logger.error(f"Timer {timer['id']}: {e}")
258
+ finally:
259
+ if timer["scope"] != base:
260
+ await set_scope(mc, base)
261
+
231
262
  async def write_handler(handler):
232
263
  try:
233
264
  while True:
@@ -752,6 +783,9 @@ def make_completion_dict(contacts, pending=None, to=None, channels=None):
752
783
  "handler_attach": {"rxlog":None, "msgs":None, "chan_data":None, "telemetry":None},
753
784
  "handler_detach": None,
754
785
  "handlers": None,
786
+ "timer": None,
787
+ "timer_cancel": None,
788
+ "timers": None,
755
789
  "login" : contact_list,
756
790
  "cmd" : contact_list,
757
791
  "req_status" : contact_list,
@@ -911,6 +945,7 @@ def make_completion_dict(contacts, pending=None, to=None, channels=None):
911
945
  "?scope":None,
912
946
  "?contact_info":None,
913
947
  "?apply_to":None,
948
+ "?timer":None,
914
949
  "?at":None,
915
950
  "?lc":None,
916
951
  "?node_discover":None,
@@ -954,6 +989,7 @@ def make_completion_dict(contacts, pending=None, to=None, channels=None):
954
989
  "unsub_telemetry" : None,
955
990
  "req_binary" : None,
956
991
  "forget_password" : None,
992
+ "timer" : None,
957
993
  }
958
994
 
959
995
  client_completion_list = dict(contact_completion_list)
@@ -1175,9 +1211,6 @@ Some cmds have an help accessible with ?<cmd>. Do ?[Tab] to get a list.
1175
1211
 
1176
1212
  last_ack = True
1177
1213
  while True:
1178
- # reset scope (if changed)
1179
- scope = await set_scope(mc, scope)
1180
-
1181
1214
  # reset sink to stdout
1182
1215
  sink = sys.stdout
1183
1216
 
@@ -1281,40 +1314,15 @@ Some cmds have an help accessible with ?<cmd>. Do ?[Tab] to get a list.
1281
1314
  if line == "quit" or line == "q" or line == "/quit" or line == "/q" :
1282
1315
  break
1283
1316
 
1284
- if line.startswith("@") and len(line) > 1: # alias => replace and resolve parameters
1285
- args = shlex.split(line[1:])
1286
- try:
1287
- alias = ALIASES[args[0]]
1288
-
1289
- if has_placeholder(alias, "c"):
1290
- if not contact is None and contact["type"] > 0:
1291
- keywords = {"c": contact['adv_name']}
1292
- pargs = args[1:]
1293
- else:
1294
- keywords = {"c": args[1]}
1295
- pargs = args[2:]
1296
- else:
1297
- keywords = {}
1298
- pargs = args[1:]
1299
-
1300
- line = formatter.format(alias, *pargs, **keywords)
1301
- except IndexError as e:
1302
- logger.error(f"Error {e}")
1303
- continue
1304
- except KeyError as e:
1305
- logger.error(f"Error {e}")
1306
- continue
1307
- except ValueError as e:
1308
- logger.error(f"Error {e}")
1309
- continue
1310
-
1311
1317
  jo = json_output
1312
1318
  if line.startswith(".") : # toggle json-output for this loop
1313
1319
  jo = True
1314
1320
  line = line[1:].strip()
1315
1321
 
1316
1322
  try:
1317
- (new_contact, new_scope, last_ack) = await process_redirected_line(mc, line, contact, scope, prev_contact, prev_scope, json_output=jo, sink=sink)
1323
+ async with CMD_LOCK:
1324
+ scope = await set_scope(mc, scope) # reset scope (if changed)
1325
+ (new_contact, new_scope, last_ack) = await process_redirected_line(mc, line, contact, scope, prev_contact, prev_scope, json_output=jo, sink=sink)
1318
1326
  except Exception as e:
1319
1327
  logger.error(f"Unexpected error: {e}")
1320
1328
  logger.debug(traceback.format_exc())
@@ -1335,14 +1343,37 @@ Some cmds have an help accessible with ?<cmd>. Do ?[Tab] to get a list.
1335
1343
  # Handle task cancellation from KeyboardInterrupt in asyncio.run()
1336
1344
  sink.write("Exiting cli\n")
1337
1345
  sink.flush()
1346
+ finally:
1347
+ for nb in list(TIMERS):
1348
+ TIMERS.pop(nb)["task"].cancel()
1338
1349
 
1339
1350
  if platform.system() == "Darwin" or platform.system() == "Windows":
1340
1351
  interactive_loop.classic = True
1341
1352
  else:
1342
1353
  interactive_loop.classic = False
1343
1354
 
1344
-
1345
1355
  async def process_redirected_line(mc, line, contact=None, scope="*", prev_contact=None, prev_scope="*", json_output=False, sink=sys.stdout, end="\n"):
1356
+ if line.startswith("@") and len(line) > 1: # alias => replace and resolve parameters
1357
+ try:
1358
+ args = shlex.split(line[1:])
1359
+ alias = ALIASES[args[0]]
1360
+
1361
+ if has_placeholder(alias, "c"):
1362
+ if not contact is None and contact["type"] > 0:
1363
+ keywords = {"c": contact['adv_name']}
1364
+ pargs = args[1:]
1365
+ else:
1366
+ keywords = {"c": args[1]}
1367
+ pargs = args[2:]
1368
+ else:
1369
+ keywords = {}
1370
+ pargs = args[1:]
1371
+
1372
+ line = formatter.format(alias, *pargs, **keywords)
1373
+ except (IndexError, KeyError, ValueError) as e:
1374
+ logger.error(f"Error {e}")
1375
+ return contact, scope, True
1376
+
1346
1377
  new_contact = contact
1347
1378
  new_scope = scope
1348
1379
  last_ack = True
@@ -1767,7 +1798,7 @@ async def process_contact_chat_line(mc, contact, line, inside=False, json_output
1767
1798
 
1768
1799
  if line.startswith("sleep ") or line.startswith("s "):
1769
1800
  try:
1770
- sleeptime = int(line.split(" ",2)[1])
1801
+ sleeptime = parse_duration(line.split(" ",2)[1])
1771
1802
  cmd_pos = 2
1772
1803
  except IndexError: # nothing arg after sleep
1773
1804
  sleeptime = 1
@@ -1826,7 +1857,7 @@ async def process_contact_chat_line(mc, contact, line, inside=False, json_output
1826
1857
 
1827
1858
  if line.startswith("set timeout "):
1828
1859
  cmds=line.split(" ")
1829
- contact["timeout"] = float(cmds[2])
1860
+ contact["timeout"] = parse_duration(cmds[2])
1830
1861
  return True
1831
1862
 
1832
1863
  if line == "get timeout":
@@ -1898,6 +1929,12 @@ async def process_contact_chat_line(mc, contact, line, inside=False, json_output
1898
1929
  # same but for commands with a parameter
1899
1930
  if " " in line:
1900
1931
  cmds = line.split(" ", 1)
1932
+
1933
+ if cmds[0] == "timer": # timer on this contact (a user-given -c still overrides)
1934
+ args = shlex.split(line, posix=True)
1935
+ await process_cmds(mc, args[:1] + ["-c" + contact["adv_name"]] + args[1:], json_output=json_output, sink=sink)
1936
+ return True
1937
+
1901
1938
  if "%" in cmds[0]:
1902
1939
  dest_scope = cmds[0].split("%")[-1]
1903
1940
  cmds[0] = cmds[0][:-len(dest_scope)-1]
@@ -1990,12 +2027,8 @@ async def apply_command_to_contacts(mc, contact_filter, line, json_output=False,
1990
2027
  elif f[0] == "u": #updated
1991
2028
  val_str = f[2:]
1992
2029
  t = time.time()
1993
- if val_str[-1] == "d": # value in days
1994
- t = t - float(val_str[0:-1]) * 86400
1995
- elif val_str[-1] == "h": # value in hours
1996
- t = t - float(val_str[0:-1]) * 3600
1997
- elif val_str[-1] == "m": # value in minutes
1998
- t = t - float(val_str[0:-1]) * 60
2030
+ if val_str[-1] in "smhd": # age
2031
+ t = t - parse_duration(val_str)
1999
2032
  else:
2000
2033
  t = int(val_str)
2001
2034
  if f[1] == "<": #before
@@ -2008,12 +2041,8 @@ async def apply_command_to_contacts(mc, contact_filter, line, json_output=False,
2008
2041
  elif f[0] == "a": # last advert
2009
2042
  val_str = f[2:]
2010
2043
  t = time.time()
2011
- if val_str[-1] == "d": # value in days
2012
- t = t - float(val_str[0:-1]) * 86400
2013
- elif val_str[-1] == "h": # value in hours
2014
- t = t - float(val_str[0:-1]) * 3600
2015
- elif val_str[-1] == "m": # value in minutes
2016
- t = t - float(val_str[0:-1]) * 60
2044
+ if val_str[-1] in "smhd": # age
2045
+ t = t - parse_duration(val_str)
2017
2046
  else:
2018
2047
  t = int(val_str)
2019
2048
  if f[1] == "<": #before
@@ -2436,7 +2465,7 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
2436
2465
  """ process next command
2437
2466
  returns (following, output_str)
2438
2467
  """
2439
- global ARROW_HEAD, SLASH_START, SLASH_END, INVERT_SLASH, LAST_HANDLER_ID
2468
+ global ARROW_HEAD, SLASH_START, SLASH_END, INVERT_SLASH, LAST_HANDLER_ID, LAST_TIMER_ID
2440
2469
  global LC_DISPLAY_TYPES, LC_OUTPUT_FORMAT, LC_SORT_ORDER
2441
2470
  global LAST_DISCOVERED_NODES
2442
2471
  output_str = ""
@@ -3496,7 +3525,7 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
3496
3525
  else:
3497
3526
  output_str += f"Unknown contact {cmds[1]}{end}"
3498
3527
  else:
3499
- contact["timeout"] = float(cmds[2])
3528
+ contact["timeout"] = parse_duration(cmds[2])
3500
3529
 
3501
3530
  case "disc_path" | "dp" :
3502
3531
  argnum = 1
@@ -3753,12 +3782,7 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
3753
3782
  else:
3754
3783
  output_str += f"Unknown contact {cmds[1]}{end}"
3755
3784
  else:
3756
- if cmds[2].endswith("m"):
3757
- duration = int(cmds[2][:-1]) * 60
3758
- elif cmds[2].endswith("h"):
3759
- duration = int(cmds[2][:-1]) * 3600
3760
- else:
3761
- duration = int(cmds[2])
3785
+ duration = int(parse_duration(cmds[2]))
3762
3786
  if cmds[3].startswith('[') or cmds[3].startswith('{'): # json
3763
3787
  min_deltas = json.loads(cmds[3])
3764
3788
  else: # custom formating: chan:type:value,
@@ -3824,22 +3848,8 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
3824
3848
  else:
3825
3849
  output_str += f"Unknown contact {cmds[1]}{end}"
3826
3850
  else:
3827
- if cmds[2][-1] == "s":
3828
- from_secs = int(cmds[2][0:-1])
3829
- elif cmds[2][-1] == "m":
3830
- from_secs = int(cmds[2][0:-1]) * 60
3831
- elif cmds[2][-1] == "h":
3832
- from_secs = int(cmds[2][0:-1]) * 3600
3833
- else :
3834
- from_secs = int(cmds[2]) * 60 # same as tdeck
3835
- if cmds[3][-1] == "s":
3836
- to_secs = int(cmds[3][0:-1])
3837
- elif cmds[3][-1] == "m":
3838
- to_secs = int(cmds[3][0:-1]) * 60
3839
- elif cmds[3][-1] == "h":
3840
- to_secs = int(cmds[3][0:-1]) * 3600
3841
- else :
3842
- to_secs = int(cmds[3]) * 60
3851
+ from_secs = int(parse_duration(cmds[2], "m")) # minutes by default, same as tdeck
3852
+ to_secs = int(parse_duration(cmds[3], "m"))
3843
3853
  timeout = 0 if not "timeout" in contact else contact["timeout"]
3844
3854
  res = await mc.commands.req_mma_sync(contact, from_secs, to_secs, timeout)
3845
3855
  if res is None :
@@ -4453,7 +4463,7 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
4453
4463
 
4454
4464
  case "sleep" | "s" :
4455
4465
  argnum = 1
4456
- await asyncio.sleep(int(cmds[1]))
4466
+ await asyncio.sleep(parse_duration(cmds[1]))
4457
4467
 
4458
4468
  case "wait_key" | "wk" :
4459
4469
  try :
@@ -4477,7 +4487,7 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
4477
4487
 
4478
4488
  case "trywait_msg" | "wmt" :
4479
4489
  argnum = 1
4480
- if await mc.wait_for_event(EventType.MESSAGES_WAITING, timeout=int(cmds[1])) :
4490
+ if await mc.wait_for_event(EventType.MESSAGES_WAITING, timeout=parse_duration(cmds[1])) :
4481
4491
  res = await mc.commands.get_msg()
4482
4492
  logger.debug(res)
4483
4493
  output_str += await process_event_message(mc, res, json_output)
@@ -4637,6 +4647,86 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
4637
4647
  case "handlers":
4638
4648
  output_str += json.dumps(HANDLERS, default=str)+end
4639
4649
 
4650
+ case "timer":
4651
+ argnum = 2 # [-j] [-c<contact>] [-s<scope>] secs line
4652
+ t_contact = None
4653
+ t_scope = set_scope.current_scope
4654
+ if t_scope is None:
4655
+ t_scope = ""
4656
+ t_json = json_output
4657
+ valid = True
4658
+
4659
+ args = cmds[1:]
4660
+ while len(args) > 0 and args[0][0] == "-":
4661
+ argnum += 1
4662
+
4663
+ if args[0].startswith("-j"): # force json output for the timer
4664
+ t_json = True
4665
+
4666
+ if args[0].startswith("-c"): # contact (~ for root)
4667
+ c = args[0][2:]
4668
+ if c == "~" or c == "/":
4669
+ t_contact = None
4670
+ else:
4671
+ t_contact = await get_contact_from_arg(mc, c)
4672
+ if t_contact is None:
4673
+ if c == "public":
4674
+ t_contact = {"adv_name" : "public", "type" : 0, "chan_nb" : 0}
4675
+ if hasattr(mc, "channels"):
4676
+ t_contact["adv_name"] = mc.channels[0]["channel_name"]
4677
+ elif c.startswith("ch") and c[2:].isnumeric():
4678
+ nb = int(c[2:])
4679
+ t_contact = {"adv_name" : c, "type" : 0, "chan_nb" : nb}
4680
+ if hasattr(mc, "channels"):
4681
+ t_contact["adv_name"] = mc.channels[nb]["channel_name"]
4682
+ else:
4683
+ chan = await get_channel_by_name(mc, c)
4684
+ if chan is None:
4685
+ valid = False
4686
+ logger.error(f"Unknown contact {c}")
4687
+ else:
4688
+ t_contact = {"adv_name": chan["channel_name"],
4689
+ "type": 0,
4690
+ "chan_nb": chan["channel_idx"],}
4691
+
4692
+ if args[0].startswith("-s"): # scope
4693
+ t_scope = args[0][2:]
4694
+
4695
+ args = args[1:]
4696
+
4697
+ if valid:
4698
+ LAST_TIMER_ID = LAST_TIMER_ID + 1
4699
+ timer = {}
4700
+ timer["id"] = LAST_TIMER_ID
4701
+ timer["secs"] = parse_duration(args[0])
4702
+ timer["cmd"] = args[1]
4703
+ timer["scope"] = t_scope
4704
+ timer["contact"] = t_contact
4705
+ timer["json"] = t_json
4706
+ timer["task"] = asyncio.create_task(run_timer(mc, timer))
4707
+ TIMERS[LAST_TIMER_ID] = timer
4708
+ if json_output:
4709
+ output_str += json.dumps(timer, default=str)+end
4710
+ else:
4711
+ output_str += f"New timer {timer['id']}{end}"
4712
+
4713
+ case "timer_cancel":
4714
+ argnum = 1
4715
+ nb = int(cmds[1])
4716
+ timer = TIMERS.pop(nb)
4717
+ timer["task"].cancel()
4718
+ try:
4719
+ await timer["task"]
4720
+ except asyncio.CancelledError:
4721
+ pass
4722
+ if json_output:
4723
+ output_str += json.dumps({"timer": timer, "status": "cancelled"}, default=str)+end
4724
+ else:
4725
+ output_str += f"Cancelled timer {nb} of cmd {timer['cmd']}{end}"
4726
+
4727
+ case "timers":
4728
+ output_str += json.dumps(TIMERS, default=str)+end
4729
+
4640
4730
  case "chat" | "im" | "interactive":
4641
4731
  # kept for retrocompatibility, but this is now not
4642
4732
  # allowed to do chat from chat so this will break the loop
@@ -4719,6 +4809,9 @@ def command_help():
4719
4809
  aliases_load : load aliases from a file
4720
4810
  handler_attach <d> <c> : attach c as a handler for d
4721
4811
  handler_detach <n> : detach an handler (from its handle n)
4812
+ timer <s> <c> : runs command c every s seconds
4813
+ timer_cancel <n> : cancels a timer (from its handle n)
4814
+ timers : lists current timers
4722
4815
  Messaging
4723
4816
  msg <name> <msg> : send message to node by name m {
4724
4817
  wait_ack : wait an ack wa }
@@ -5160,6 +5253,22 @@ meshcore-cli lets you attach shell process to msg rx_log chan_data or telemetry
5160
5253
 
5161
5254
  * `handler_detach <n>` detaches handler with number `n`
5162
5255
  * `handlers` lists current handlers
5256
+ """)
5257
+
5258
+ elif "timer" in cmdname:
5259
+ print("""timer [-j] [-c<contact>] [-s<scope>] <s> <line>: runs line every s seconds (s can be postfixed with s, m, h or d)
5260
+
5261
+ * args:
5262
+ - `-j` forces json output for the timed line.
5263
+ - `-c` sets the contact the line is run from (`~` for root).
5264
+ - `-s` sets the scope for the line, defaults to the current scope.
5265
+
5266
+ * `timer_cancel <n>` cancels timer number `n`
5267
+ * `timers` lists current timers
5268
+
5269
+ * Note:
5270
+ - The line has to be quoted if it has more than one word, redirections can be used inside the quotes.
5271
+
5163
5272
  """)
5164
5273
 
5165
5274
  else:
@@ -5690,7 +5799,7 @@ async def main(argv):
5690
5799
  usage()
5691
5800
  return
5692
5801
  case "-T" :
5693
- timeout = float(arg)
5802
+ timeout = parse_duration(arg)
5694
5803
  case "-v":
5695
5804
  version()
5696
5805
  return
File without changes
File without changes
File without changes
File without changes