Skip to content

Commit

Permalink
Merge pull request #10101 from dra27/ocamlrun-help
Browse files Browse the repository at this point in the history
Add -help/--help option to ocamlrun
  • Loading branch information
dra27 committed Jan 4, 2021
2 parents 87b2678 + bf1f8e7 commit 8cf4ab6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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

0 comments on commit 8cf4ab6

Please sign in to comment.