Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -help/--help option to ocamlrun #10101

Merged
merged 1 commit into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Working version
parsing.
(David Allsopp, review by Xavier Leroy)

- #10101: Add -help/--help option to ocamlrun.
(David Allsopp, review by Xavier Leroy)

### Code generation and optimizations:

- #9876: do not cache the young_limit GC variable in a processor register.
Expand Down
23 changes: 23 additions & 0 deletions runtime/startup_byt.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,25 @@ static char_os * read_section_to_os(int fd, struct exec_trailer *trail,

*/

static void do_print_help(void)
{
printf("%s\n",
"Usage: ocamlrun [<options>] [--] <executable> [<command-line>]\n"
"Options are:\n"
" -b Set runtime parameter b (detailed exception backtraces)\n"
" -I <dir> Add <dir> to the list of DLL search directories\n"
" -m Print the magic number of <executable> and exit\n"
" -M Print the magic number expected by this runtime and exit\n"
" -p Print the names of the primitives known to this runtime\n"
" -t Trace the execution of the bytecode interpreter (specify multiple\n"
" times to increase verbosity)\n"
" -v Set runtime parameter v=61 (GC event information)\n"
" -version Print version string and exit\n"
" -vnum Print short version number and exit\n"
" -help Display this list of options\n"
" --help Display this list of options");
}

/* Parse options on the command line */

static int parse_command_line(char_os **argv)
Expand Down Expand Up @@ -328,6 +347,10 @@ static int parse_command_line(char_os **argv)
} else if (!strcmp_os(argv[i], T("-vnum"))) {
printf("%s\n", OCAML_VERSION_STRING);
exit(0);
} else if (!strcmp_os(argv[i], T("-help")) ||
!strcmp_os(argv[i], T("--help"))) {
do_print_help();
exit(0);
} else {
parsed = 0;
}
Expand Down