sleep defaults to one second

This commit is contained in:
Kovid Goyal 2022-11-22 21:54:51 +05:30
parent c0d06adcb5
commit 2b676b63b1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 2 deletions

View File

@ -1774,8 +1774,8 @@ class Boss:
else:
doit()
@ac('misc', 'Sleep for the specified time period')
def sleep(self, sleep_time: float) -> None:
@ac('misc', 'Sleep for the specified time period. Suffix can be s for seconds, m, for minutes, h for hours and d for days. The time can be fractional.')
def sleep(self, sleep_time: float = 1.0) -> None:
sleep(sleep_time)
@ac('misc', 'Click a URL using the keyboard')

View File

@ -296,6 +296,7 @@ def single_integer_arg(func: str, rest: str) -> FuncArgsType:
@func_with_args('sleep')
def sleep(func: str, sleep_time: str) -> FuncArgsType:
mult = 1
sleep_time = sleep_time or '1'
if sleep_time[-1] in 'shmd':
mult = {'s': 1, 'm': 60, 'h': 3600, 'd': 24 * 3600}[sleep_time[-1]]
sleep_time = sleep_time[:-1]