Help message (-h or --help)

This commit is contained in:
Aleksandr Lebedev 2026-04-21 17:52:39 +02:00
parent d20c1c429e
commit 97505583b1

12
main.c
View file

@ -1054,6 +1054,18 @@ char* generate_ps1_prompt()
int main(int argc, const char* argv[])
{
const bool show_help = argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0);
if(show_help)
{
printf("Arsh is a simple shell for Unix-like systems written in C, that has a funny name (for germans).\n\n");
printf("Usage:\n");
printf("- Start %s without arguments to use arsh shell interactively\n", argv[0]);
printf("- Start %s with a path to a script to launch it\n", argv[0]);
printf("- Start %s with a '-c' argument and a command afterwards to execute a specific command\n", argv[0]);
printf("- Start %s with a '-h' or '--help' argument to see this message\n", argv[0]);
exit(0);
}
setenv("SHELL", argv[0], 1);
FILE* stream = stdin;
char* prompt = generate_ps1_prompt();