From 2c93b57c340261610320d33aed251e6e7f983cfa Mon Sep 17 00:00:00 2001 From: TNT_TS Date: Wed, 1 Jul 2026 21:01:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3help=E8=A1=8C=E4=B8=BA?= =?UTF-8?q?=EF=BC=8C=E7=BE=8E=E5=8C=96help=E6=8F=8F=E8=BF=B0=E6=96=87?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.c | 36 +++++++++++++++++++++++++----------- src/shell.c | 14 +++++++++----- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/main.c b/src/main.c index 8e0c20f..dbc1665 100644 --- a/src/main.c +++ b/src/main.c @@ -25,18 +25,32 @@ int main(void) { /* 注册文件系统命令 */ shellRegister("mkfile", doMkfile, - "mkfile \nCreate a file with given size"); - shellRegister("mkdir", doMkdir, "mkdir \nCreate a subdirectory"); - shellRegister("rm", doRm, "rm \nDelete a file"); + UNDERLINE "mkfile \n" COLOR_RESET + "Create a file with given size"); + shellRegister("mkdir", doMkdir, + UNDERLINE "mkdir \n" COLOR_RESET "Create a subdirectory"); + shellRegister("rm", doRm, + UNDERLINE "rm \n" COLOR_RESET "Delete a file"); shellRegister("rmdir", doRmdir, - "rmdir \nDelete a subdirectory (must be empty)"); - shellRegister("ls", doLs, "ls [path]\nList directory contents"); - shellRegister("open", doOpen, "open \nOpen a file, returns fd"); - shellRegister("close", doClose, "close \nClose a file by fd"); - shellRegister("read", doRead, "read \nRead from file and print"); - shellRegister("write", doWrite, "write \nWrite data to file"); - shellRegister("df", doDf, "df\nShow disk usage statistics"); - shellRegister("viz", doViz, "viz\nToggle visualization on/off"); + UNDERLINE "rmdir \n" COLOR_RESET + "Delete a subdirectory (must be empty)"); + shellRegister("ls", doLs, + UNDERLINE "ls [path]\n" COLOR_RESET "List directory contents"); + shellRegister("open", doOpen, + UNDERLINE "open \n" COLOR_RESET + "Open a file, returns fd"); + shellRegister("close", doClose, + UNDERLINE "close \n" COLOR_RESET "Close a file by fd"); + shellRegister("read", doRead, + UNDERLINE "read \n" COLOR_RESET + "Read from file and print"); + shellRegister("write", doWrite, + UNDERLINE "write \n" COLOR_RESET + "Write data to file"); + shellRegister("df", doDf, + UNDERLINE "df\n" COLOR_RESET "Show disk usage statistics"); + shellRegister("viz", doViz, + UNDERLINE "viz\n" COLOR_RESET "Toggle visualization on/off"); /* 初始化 Shell */ if (shellInit("root") != 0) { diff --git a/src/shell.c b/src/shell.c index ab2f733..f6ed5ce 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1,4 +1,5 @@ #include "shell.h" +#include "common.h" #include "log.h" #include #include @@ -186,10 +187,14 @@ int shellInit(char *username) { return EXIT_FAILURE; } - shellRegister("echo", doEcho, "echo \nEcho what you input"); - shellRegister("help", doHelp, "help \nShow helptext of command"); + shellRegister("echo", doEcho, + UNDERLINE "echo \n" COLOR_RESET "Echo what you input"); + shellRegister("help", doHelp, + UNDERLINE "help \n" COLOR_RESET + "Show helptext of command"); shellRegister("exit", doExit, - "exit \nExit shell with "); + UNDERLINE "exit \n" COLOR_RESET + "Exit shell with "); return 0; } @@ -257,7 +262,7 @@ static int doHelp(int argc, char **argv) { if (argc == 1) { for (int idx = 0; idx < CMDSIZE_MAX; idx++) { if (cmdBucket[idx].occupied == 1) { - printf("%s\n", cmdBucket[idx].help); + printf("%s\n\n", cmdBucket[idx].help); } } } @@ -270,7 +275,6 @@ static int doHelp(int argc, char **argv) { goto err; } - printf("%s\n", cmdBucket[idx].help); return 0; err: