apps/nshlib: add uptime command support

run uptime command on sim:
nsh>
nsh>
nsh> uptime
19:35:01 up  1:40, load average: 0.00, 0.00, 0.00
nsh>
nsh>
nsh> uptime -s
2022-09-16 17:54:26
nsh>
nsh>
nsh> uptime -p
up 1 hour, 40 minutes
nsh>
nsh>
nsh> uptime -h
Usage:
uptime [options]
Options:
-p, show uptime in pretty format
-h, display this help and exit
-s, system up since
nsh>
nsh>
nsh> uptime -abc
uptime: invalid option -- -abc
Usage:
uptime [options]
Options:
-p, show uptime in pretty format
-h, display this help and exit
-s, system up since
nsh>
nsh>
nsh> date
Fri, Sep 16 19:35:18 2022
nsh>
nsh>

Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
This commit is contained in:
Junbo Zheng
2022-09-12 15:43:36 +08:00
committed by Petro Karashchenko
parent ac4b42fee7
commit 06f39d10f1
4 changed files with 134 additions and 0 deletions

View File

@@ -564,6 +564,10 @@ static const struct cmdmap_s g_cmdmap[] =
{ "unset", cmd_unset, 2, 2, "<name>" },
#endif
#ifndef CONFIG_NSH_DISABLE_UPTIME
{ "uptime", cmd_uptime, 1, 2, "[-sph]" },
#endif
#if defined(CONFIG_NETUTILS_CODECS) && defined(CONFIG_CODECS_URLCODE)
# ifndef CONFIG_NSH_DISABLE_URLDECODE
{ "urldecode", cmd_urldecode, 2, 3, "[-f] <string or filepath>" },