Unopinionated, no-frills CLI argument parser for Node.js applications
Overall
score
99%
Build a command-line argument parser for a logging utility that supports multiple ways to specify verbosity levels through aliased argument names.
Your parser should support the following verbosity configurations:
--verbosity that accepts a number (0-3)-v that acts as an alias to --verbosity--log-level that also aliases to --verbosity-d that aliases to --log-level (which in turn aliases to --verbosity)The parser should resolve all these aliases to a single canonical result key, regardless of which variant the user provides.
The parser should accept command-line arguments as an array of strings (simulating process.argv.slice(2)).
Return a parsed result object where:
verbosity contains the resolved value_ array--verbosity 2 returns { verbosity: 2, _: [] } @test-v 1 returns { verbosity: 1, _: [] } @test--log-level 3 returns { verbosity: 3, _: [] } @test-d 2 returns { verbosity: 2, _: [] } @test@generates
/**
* Parses command-line arguments with alias chain resolution
*
* @param {string[]} argv - Array of command-line arguments
* @returns {Object} Parsed arguments with canonical names
*/
function parseArgs(argv) {
// Implementation here
}
module.exports = { parseArgs };Provides command-line argument parsing with alias support.
@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