Unopinionated, no-frills CLI argument parser for Node.js applications
Overall
score
99%
Build a command-line tool that accepts its own configuration options while collecting additional unrecognized arguments to pass through to a subcommand.
Your tool should parse command-line arguments with the following behavior:
--verbose flag (boolean) for verbose output--config option (string) for configuration file path-- terminator to treat all following arguments as positionalWhen given --verbose --config=/path/to/config.json build deploy --force, should return verbose: true, config: "/path/to/config.json", and collected arguments ["build", "deploy", "--force"] @test
When given --verbose -- --config something, should return verbose: true, and collected arguments ["--config", "something"] (everything after -- is positional) @test
When given build test deploy, should return collected arguments ["build", "test", "deploy"] with no parsed options @test
When given --config=app.json command1 command2, should return config: "app.json" and collected arguments ["command1", "command2"] @test
@generates
/**
* Parses command-line arguments, extracting known options and collecting
* positional arguments.
*
* @param {string[]} argv - The argument array to parse (e.g., process.argv.slice(2))
* @returns {object} An object containing parsed options and a '_' property with positional arguments
*/
function parseArgs(argv) {
// Implementation here
}
module.exports = { parseArgs };CLI argument parser that supports option parsing and positional argument collection.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-argdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10