Help message (-h or --help)
This commit is contained in:
parent
d20c1c429e
commit
97505583b1
1 changed files with 12 additions and 0 deletions
12
main.c
12
main.c
|
|
@ -1054,6 +1054,18 @@ char* generate_ps1_prompt()
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
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);
|
setenv("SHELL", argv[0], 1);
|
||||||
FILE* stream = stdin;
|
FILE* stream = stdin;
|
||||||
char* prompt = generate_ps1_prompt();
|
char* prompt = generate_ps1_prompt();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue