Skip to content

Commit

Permalink
Add ocamlrun -help/--help
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 committed Feb 5, 2020
1 parent 5e38843 commit d2c2f53
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Working version
parsing and permit gcc-style `-Ifoo` for `-I foo`.
(David Allsopp, review by ???)

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

### Code generation and optimizations:

- #9937: improvements in ARM64 code generation (constants, sign extensions)
Expand Down
21 changes: 21 additions & 0 deletions runtime/startup_byt.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,23 @@ static char_os * read_section_to_os(int fd, struct exec_trailer *trail,
*/

static void do_print_help(void)
{
puts("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 Increments the trace level in debug mode by 1\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 @@ -327,6 +344,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 if (argv[i][1] == 'I') {
caml_ext_table_add(&caml_shared_libs_path, &argv[i][2]);
} else {
Expand Down

0 comments on commit d2c2f53

Please sign in to comment.