Skip to content

src,cli: make CLI options programmatically accessible & generate --help text #22490

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 4 commits into from

Conversation

addaleax
Copy link
Member

@addaleax addaleax commented Aug 23, 2018

`node --help` before:
Usage: node [options] [ -e script | script.js | - ] [arguments]
       node inspect script.js [arguments]

Options:
  -                          script read from stdin (default; 
                             interactive mode if a tty)
  --                         indicate the end of node options
  --abort-on-uncaught-exception
                             aborting instead of exiting causes a
                             core file to be generated for analysis
  --experimental-modules     experimental ES Module support
                             and caching modules
  --experimental-repl-await  experimental await keyword support
                             in REPL
  --experimental-vm-modules  experimental ES Module support
                             in vm module
  --experimental-worker      experimental threaded Worker support
  --icu-data-dir=dir         set ICU data load path to dir
                             (overrides NODE_ICU_DATA)
  --inspect-brk[=[host:]port]
                             activate inspector on host:port
                             and break at start of user script
  --inspect-port=[host:]port
                             set host:port for inspector
  --inspect[=[host:]port]    activate inspector on host:port
                             (default: 127.0.0.1:9229)
  --napi-modules             load N-API modules (no-op - option
                             kept for compatibility)
  --no-deprecation           silence deprecation warnings
  --no-force-async-hooks-checks
                             disable checks for async_hooks
  --no-warnings              silence all process warnings
  --openssl-config=file      load OpenSSL configuration from the
                             specified file (overrides
                             OPENSSL_CONF)
  --pending-deprecation      emit pending deprecation warnings
  --preserve-symlinks        preserve symbolic links when resolving
  --preserve-symlinks-main   preserve symbolic links when resolving
                             the main module
  --prof                     generate V8 profiler output
  --prof-process             process V8 profiler output generated
                             using --prof
  --redirect-warnings=file
                             write warnings to file instead of
                             stderr
  --throw-deprecation        throw an exception on deprecations
  --title=title              the process title to use on start up
  --tls-cipher-list=val      use an alternative default TLS cipher list
  --trace-deprecation        show stack traces on deprecations
  --trace-event-categories   comma separated list of trace event
                             categories to record
  --trace-event-file-pattern Template string specifying the
                             filepath for the trace-events data, it
                             supports ${rotation} and ${pid}
                             log-rotation id. %2$u is the pid.
  --trace-events-enabled     track trace events
  --trace-sync-io            show stack trace when use of sync IO
                             is detected after the first tick
  --trace-warnings           show stack traces on process warnings
  --track-heap-objects       track heap object allocations for heap snapshots
  --use-bundled-ca           use bundled CA store (default)
  --use-openssl-ca           use OpenSSL's default CA store
  --v8-options               print v8 command line options
  --v8-pool-size=num         set v8's thread pool size
  --zero-fill-buffers        automatically zero-fill all newly allocated
                             Buffer and SlowBuffer instances
  -c, --check                syntax check script without executing
  -e, --eval script          evaluate script
  -h, --help                 print node command line options
  -i, --interactive          always enter the REPL even if stdin
                             does not appear to be a terminal
  -p, --print                evaluate script and print result
  -r, --require              module to preload (option can be repeated)
  -v, --version              print Node.js version

Environment variables:
NODE_DEBUG                   ','-separated list of core modules
                             that should print debug information
NODE_DEBUG_NATIVE            ','-separated list of C++ core debug
                             categories that should print debug
                             output
NODE_DISABLE_COLORS          set to 1 to disable colors in the REPL
NODE_EXTRA_CA_CERTS          path to additional CA certificates
                             file
NODE_ICU_DATA                data path for ICU (Intl object) data
NODE_NO_WARNINGS             set to 1 to silence process warnings
NODE_OPTIONS                 set CLI options in the environment
                             via a space-separated list
NODE_PATH                    ':'-separated list of directories
                             prefixed to the module search path
NODE_PENDING_DEPRECATION     set to 1 to emit pending deprecation
                             warnings
NODE_PRESERVE_SYMLINKS       set to 1 to preserve symbolic links
                             when resolving and caching modules
NODE_REDIRECT_WARNINGS       write warnings to path instead of
                             stderr
NODE_REPL_HISTORY            path to the persistent REPL history
                             file
OPENSSL_CONF                 load OpenSSL configuration from file

Documentation can be found at https://nodejs.org/
`node --help` after:
Usage: node [options] [ -e script | script.js | - ] [arguments]
       node inspect script.js [arguments]

Options:
  -                           script read from stdin (default;
                              interactive mode if a tty)
  --                          indicate the end of node options
  --abort_on_uncaught_exception
                              aborting instead of exiting causes a
                              core file to be generated for analysis
  -c, --check                 syntax check script without executing
  -e, --eval=...              evaluate script
  --experimental-modules      experimental ES Module support and
                              caching modules
  --experimental-repl-await   experimental await keyword support in
                              REPL
  --experimental-vm-modules   experimental ES Module support in vm
                              module
  --experimental-worker       experimental threaded Worker support
  -h, --help                  print node command line options
                              (currently set)
  --icu-data-dir=...          set ICU data load path to dir (overrides
                              NODE_ICU_DATA)
  --inspect[=[host:]port]     activate inspector on host:port
                              (default: 127.0.0.1:9229)
  --inspect-brk[=[host:]port] activate inspector on host:port and
                              break at start of user script
  --debug-port, --inspect-port=[host:]port
                              set host:port for inspector
  -i, --interactive           always enter the REPL even if stdin does
                              not appear to be a terminal
  --loader=...                (with --experimental-modules) use the
                              specified file as a custom loader
  --no-deprecation            silence deprecation warnings
  --no-force-async-hooks-checks
                              disable checks for async_hooks
  --no-warnings               silence all process warnings
  --openssl-config=...        load OpenSSL configuration from the
                              specified file (overrides OPENSSL_CONF)
  --pending-deprecation       emit pending deprecation warnings
                              (currently set)
  --preserve-symlinks         preserve symbolic links when resolving
  --preserve-symlinks-main    preserve symbolic links when resolving
                              the main module
  -p, --print [...]           evaluate script and print result
  --prof-process              process V8 profiler output generated
                              using --prof
  --redirect-warnings=...     write warnings to file instead of stderr
  -r, --require=...           module to preload (option can be
                              repeated)
  --throw-deprecation         throw an exception on deprecations
  --title=...                 the process title to use on startup
  --tls-cipher-list=...       use an alternative default TLS cipher
                              list
  --trace-deprecation         show stack traces on deprecations
  --trace-event-categories=...
                              comma separated list of trace event
                              categories to record
  --trace-event-file-pattern=...
                              Template string specifying the filepath
                              for the trace-events data, it supports
                              ${rotation} and ${pid} log-rotation id.
                              %2$u is the pid.
  --trace-sync-io             show stack trace when use of sync IO is
                              detected after the first tick
  --trace-warnings            show stack traces on process warnings
                              (currently set)
  --track-heap-objects        track heap object allocations for heap
                              snapshots
  --use-bundled-ca            use bundled CA store (default)
  --use-openssl-ca            use OpenSSL's default CA store
  --v8-options                print V8 command line options
  --v8-pool-size=...          set V8's thread pool size
  -v, --version               print Node.js version
  --zero-fill-buffers         automatically zero-fill all newly
                              allocated Buffer and SlowBuffer
                              instances
  
Environment variables:
NODE_DEBUG                  ','-separated list of core modules that
                            should print debug information
NODE_DEBUG_NATIVE           ','-separated list of C++ core debug
                            categories that should print debug
                            output
NODE_DISABLE_COLORS         set to 1 to disable colors in the REPL
NODE_EXTRA_CA_CERTS         path to additional CA certificates file
NODE_NO_WARNINGS            set to 1 to silence process warnings
NODE_OPTIONS                set CLI options in the environment via a
                            space-separated list
NODE_PATH                   ':'-separated list of directories
                            prefixed to the module search path
NODE_PENDING_DEPRECATION    set to 1 to emit pending deprecation
                            warnings
NODE_PRESERVE_SYMLINKS      set to 1 to preserve symbolic links when
                            resolving and caching modules
NODE_REDIRECT_WARNINGS      write warnings to path instead of stderr
NODE_REPL_HISTORY           path to the persistent REPL history file
OPENSSL_CONF                load OpenSSL configuration from file

Documentation can be found at https://nodejs.org/
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@addaleax addaleax added the cli Issues and PRs related to the Node.js command line interface. label Aug 23, 2018
@nodejs-github-bot
Copy link
Collaborator

@addaleax sadly an error occured when I tried to trigger a build :(

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Aug 23, 2018
@addaleax
Copy link
Member Author

Also, /cc @boneskull for the first commit

@addaleax
Copy link
Member Author

@addaleax
Copy link
Member Author

Provide `internalBinding('options')` with some utilities
around making the options parser and current options values
programatically accessible.
Instead of having a custom, static, hand-written string
that is being printed to stdout when `--help` is present,
generate it in JS when requested.
@addaleax
Copy link
Member Author

@addaleax
Copy link
Member Author

addaleax commented Aug 28, 2018

CI: https://ci.nodejs.org/job/node-test-pull-request/16823/ (:heavy_check_mark:)

@addaleax
Copy link
Member Author

CI is good. Anything I can do to attract reviewers without having to go into making noisy pings…? ;)

@targos
Copy link
Member

targos commented Aug 31, 2018

I will try to the best of my ability

Copy link
Member

@targos targos left a comment

Choose a reason for hiding this comment

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

Well, I have nothing to say. This is really nice 😄

@addaleax
Copy link
Member Author

Thanks for the review! :) The next PRs on this topic should be a bit lighter. 😄

Landed in e812be4, c8880ea

@addaleax addaleax closed this Aug 31, 2018
addaleax added a commit that referenced this pull request Aug 31, 2018
Provide `internalBinding('options')` with some utilities
around making the options parser and current options values
programatically accessible.

PR-URL: #22490
Reviewed-By: Michaël Zasso <targos@protonmail.com>
addaleax added a commit that referenced this pull request Aug 31, 2018
Instead of having a custom, static, hand-written string
that is being printed to stdout when `--help` is present,
generate it in JS when requested.

PR-URL: #22490
Reviewed-By: Michaël Zasso <targos@protonmail.com>
@addaleax addaleax deleted the options2 branch August 31, 2018 22:26
@targos
Copy link
Member

targos commented Sep 1, 2018

This will need a small backport to v10.x-staging.

addaleax added a commit to addaleax/node that referenced this pull request Sep 1, 2018
Provide `internalBinding('options')` with some utilities
around making the options parser and current options values
programatically accessible.

PR-URL: nodejs#22490
Reviewed-By: Michaël Zasso <targos@protonmail.com>
addaleax added a commit to addaleax/node that referenced this pull request Sep 1, 2018
Instead of having a custom, static, hand-written string
that is being printed to stdout when `--help` is present,
generate it in JS when requested.

PR-URL: nodejs#22490
Reviewed-By: Michaël Zasso <targos@protonmail.com>
targos pushed a commit that referenced this pull request Sep 2, 2018
Provide `internalBinding('options')` with some utilities
around making the options parser and current options values
programatically accessible.

Backport-PR-URL: #22644
PR-URL: #22490
Reviewed-By: Michaël Zasso <targos@protonmail.com>
targos pushed a commit that referenced this pull request Sep 2, 2018
Instead of having a custom, static, hand-written string
that is being printed to stdout when `--help` is present,
generate it in JS when requested.

Backport-PR-URL: #22644
PR-URL: #22490
Reviewed-By: Michaël Zasso <targos@protonmail.com>
@refack
Copy link
Contributor

refack commented Sep 2, 2018

@addaleax due to a misconfigured job in CI the job was marked "Unstable" even tough this has a failed test
Job: https://ci.nodejs.org/job/node-test-commit-linux-containered/6748/
Failed test: https://ci.nodejs.org/job/node-test-commit-linux-containered/6748/nodes=ubuntu1604_sharedlibs_withoutintl_x64/testReport/junit/(root)/test/parallel_test_cli_node_print_help/

assert.js:84
  throw new AssertionError(obj);
  ^

AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:

1194 !== -1

    at options.flags.forEach (/home/iojs/build/workspace/node-test-commit-linux-containered/nodes/ubuntu1604_sharedlibs_withoutintl_x64/test/parallel/test-cli-node-print-help.js:51:14)
    at Array.forEach (<anonymous>)
    at testForSubstring (/home/iojs/build/workspace/node-test-commit-linux-containered/nodes/ubuntu1604_sharedlibs_withoutintl_x64/test/parallel/test-cli-node-print-help.js:50:19)
    at Array.forEach (<anonymous>)
    at validateNodePrintHelp (/home/iojs/build/workspace/node-test-commit-linux-containered/nodes/ubuntu1604_sharedlibs_withoutintl_x64/test/parallel/test-cli-node-print-help.js:41:18)
    at common.mustCall (/home/iojs/build/workspace/node-test-commit-linux-containered/nodes/ubuntu1604_sharedlibs_withoutintl_x64/test/parallel/test-cli-node-print-help.js:17:5)
    at /home/iojs/build/workspace/node-test-commit-linux-containered/nodes/ubuntu1604_sharedlibs_withoutintl_x64/test/common/index.js:435:15
    at ChildProcess.exithandler (child_process.js:281:7)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:964:16)

@addaleax
Copy link
Member Author

addaleax commented Sep 2, 2018

@refack Does “was” mean that it’s fixed now and will fail every time? If so, we should land #22657 immediately.

@refack
Copy link
Contributor

refack commented Sep 2, 2018

Does “was” mean that it’s fixed now and will fail every time? If so, we should land #22657 immediately.

I'm running a test to see if the job will now fail. If #22657 doesn't get fast-tracked I'll revert that change for the time being.

Update: https://ci.nodejs.org/job/node-test-commit-linux-containered/6806/nodes=ubuntu1604_sharedlibs_withoutintl_x64/console, configuration fixed. Now the job fails.

targos pushed a commit that referenced this pull request Sep 3, 2018
Provide `internalBinding('options')` with some utilities
around making the options parser and current options values
programatically accessible.

Backport-PR-URL: #22644
PR-URL: #22490
Reviewed-By: Michaël Zasso <targos@protonmail.com>
targos pushed a commit that referenced this pull request Sep 3, 2018
Instead of having a custom, static, hand-written string
that is being printed to stdout when `--help` is present,
generate it in JS when requested.

Backport-PR-URL: #22644
PR-URL: #22490
Reviewed-By: Michaël Zasso <targos@protonmail.com>
targos pushed a commit that referenced this pull request Sep 6, 2018
Provide `internalBinding('options')` with some utilities
around making the options parser and current options values
programatically accessible.

Backport-PR-URL: #22644
PR-URL: #22490
Reviewed-By: Michaël Zasso <targos@protonmail.com>
targos pushed a commit that referenced this pull request Sep 6, 2018
Instead of having a custom, static, hand-written string
that is being printed to stdout when `--help` is present,
generate it in JS when requested.

Backport-PR-URL: #22644
PR-URL: #22490
Reviewed-By: Michaël Zasso <targos@protonmail.com>
sam-github added a commit to sam-github/node that referenced this pull request Aug 15, 2019
It was called --security-revert prior to 12.x, but changed in
nodejs#22490.

See:
nodejs/nodejs.org#2412 (comment)
Trott pushed a commit that referenced this pull request Aug 17, 2019
It was called --security-revert prior to 12.x, but changed in
#22490.

See:
nodejs/nodejs.org#2412 (comment)

PR-URL: #29153
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Aug 19, 2019
It was called --security-revert prior to 12.x, but changed in
#22490.

See:
nodejs/nodejs.org#2412 (comment)

PR-URL: #29153
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. cli Issues and PRs related to the Node.js command line interface. lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants