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

@@ -1204,6 +1204,10 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
int cmd_usleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
#endif
#ifndef CONFIG_NSH_DISABLE_UPTIME
int cmd_uptime(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
#endif
#if defined(CONFIG_NETUTILS_CODECS) && defined(CONFIG_CODECS_BASE64)
# ifndef CONFIG_NSH_DISABLE_BASE64DEC
int cmd_base64decode(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);