-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Feature Request: ability to hide options #1106
Description
Ask:
Provide a .noHelp() command for an option to opt-out of the default help generation or update the .allowUnknownOptions command to take a list of accepted "unknown" options and store any of those which are passed somewhere within the program for access.
const commander = require('../');
const program = new commander.Command();
// unknown options
program.allowUnknownOptions(['--super-special-pizza']);
program
.option('-h, --hawaiian', 'Create a sad pizza')
// noHelp
.noHelp();Context:
Currently, there is no ability to hide options other than to manually parse process.argv in search of the specific options that you want and then strip those out of what you pass to program.parse.
I am working on an internally open-sourced CLI that takes advantage of feature flags to determine whether a command is in development, beta, production, or deprecated. The CLI is dynamically populated with the available commands depending on the user's self-declared "level" in a configuration file.
Use 1
In order to make our testing more robust, we'd like to be able to pass --[dev|beta|prod] in on the command line that will override that configuration file, making it so that we need fewer configuration files in order to run integration and e2e tests on the full suite.
Use 2:
Once we integrate with the API that is in development, we will want to pass a --test [endpoint] flag to the code during e2e tests to inform it that it needs to use that specific endpoint for the test-session and the test-specific headers that are required for a test session.