Unopinionated, no-frills CLI argument parser for Node.js applications
Overall
score
99%
Build a command-line argument parser that processes server configuration options and returns a configuration object.
Your parser should accept command-line arguments using the equals syntax (e.g., --option=value) and return a parsed configuration object. The parser must handle:
--host=example.com and output {"host": "example.com"} @test--port=8080 and output {"port": 8080} @test--root=/var/www/html and output {"root": "/var/www/html"} @test--log=/var/log/app.log and output {"log": "/var/log/app.log"} @test--root=/path/with/multiple/dirs and output {"root": "/path/with/multiple/dirs"} @test--max-size=100 and output {"maxSize": 100} @test--port=3000 --max-size=50 and output {"port": 3000, "maxSize": 50} @test--api-key=abc123=def456 and output {"apiKey": "abc123=def456"} @test--host=api.example.com and output {"host": "api.example.com"} @test--https and output {"https": true} @test--https --port=443 and output {"https": true, "port": 443} @test@generates
/**
* Parses command-line arguments and generates a configuration object.
*
* @param {string[]} argv - Array of command-line arguments to parse
* @returns {Object} Configuration object with parsed values
*/
function parseConfig(argv) {
// Implementation using arg package
}
module.exports = { parseConfig };Provides command-line argument parsing with support for equals syntax.
@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