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 a CLI help mode to show hidden opts. #30392

Merged
merged 1 commit into from
Dec 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jl_options_t jl_options = { 0, // quiet
static const char usage[] = "julia [switches] -- [programfile] [args...]\n";
static const char opts[] =
" -v, --version Display version information\n"
" -h, --help Print this message\n\n"
" -h, --help Print this message (--help-hidden for more)\n\n"

// startup options
" --project[={<dir>|@.}] Set <dir> as the home project/environment\n"
Expand Down Expand Up @@ -110,7 +110,6 @@ static const char opts[] =
" --warn-overwrite={yes|no} Enable or disable method overwrite warnings\n\n"

// code generation options
//" --compile={yes|no|all|min}Enable or disable JIT compiler, or request exhaustive compilation\n"
" -C, --cpu-target <target> Limit usage of CPU features up to <target>; set to \"help\" to see the available options\n"
" -O, --optimize={0,1,2,3} Set the optimization level (default level is 2 if unspecified or 3 if used without a level)\n"
" -g, -g <level> Enable / Set the level of debug info generation"
Expand All @@ -131,17 +130,21 @@ static const char opts[] =
" Count executions of source lines (omitting setting is equivalent to \"user\")\n"
" --track-allocation={none|user|all}, --track-allocation\n"
" Count bytes allocated by each source line\n\n"
;

static const char opts_hidden[] =
// code generation options
" --compile={yes|no|all|min}Enable or disable JIT compiler, or request exhaustive compilation\n"

// compiler output options
//" --output-o name Generate an object file (including system image data)\n"
//" --output-ji name Generate a system image data file (.ji)\n"
// These are for compiler debugging purposes only and should not be otherwise
// used, so don't show them here. See the devdocs for tips on using these
// options for debugging the compiler.
// " --output-unopt-bc name Generate unoptimized LLVM bitcode (.bc)\n"
// " --output-jit-bc name Dump all IR generated by the frontend (not including system image)\n"
//" --output-bc name Generate LLVM bitcode (.bc)\n"
//" --output-incremental=no Generate an incremental output file (rather than complete)\n\n"
" --output-o name Generate an object file (including system image data)\n"
" --output-ji name Generate a system image data file (.ji)\n"

// compiler debugging (see the devdocs for tips on using these options)
" --output-unopt-bc name Generate unoptimized LLVM bitcode (.bc)\n"
" --output-jit-bc name Dump all IR generated by the frontend (not including system image)\n"
" --output-bc name Generate LLVM bitcode (.bc)\n"
" --output-incremental=no Generate an incremental output file (rather than complete)\n\n"
;

JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
Expand Down Expand Up @@ -171,6 +174,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
opt_use_precompiled,
opt_use_compilecache,
opt_incremental,
opt_help_hidden,
opt_banner,
opt_sysimage_native_code,
opt_compiled_modules,
Expand All @@ -184,6 +188,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
// with the required arguments defined in base/client.jl `process_options()`
{ "version", no_argument, 0, 'v' },
{ "help", no_argument, 0, 'h' },
{ "help-hidden", no_argument, 0, opt_help_hidden },
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about calling this help-all instead? Or maybe passing --help twice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same to me. -help-hidden is what LLVM uses, and I mimicked.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose matching LLVM for this does make sense.

{ "quiet", no_argument, 0, 'q' },
{ "banner", required_argument, 0, opt_banner },
{ "home", required_argument, 0, 'H' },
Expand Down Expand Up @@ -291,6 +296,9 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
case 'h': // help
jl_printf(JL_STDOUT, "%s%s", usage, opts);
jl_exit(0);
case opt_help_hidden:
jl_printf(JL_STDOUT, "%s%s", usage, opts_hidden);
jl_exit(0);
case 'g': // debug info
if (optarg != NULL) {
if (!strcmp(optarg,"0"))
Expand Down