Unopinionated, no-frills CLI argument parser for Node.js applications
Overall
score
99%
A CLI argument parser for configuring a development server.
The parser should handle command-line arguments to configure a development server with the following options:
--host: A string specifying the hostname (e.g., "localhost", "0.0.0.0")--port: A numeric value specifying the port number (e.g., 3000, 8080)--verbose: A boolean flag to enable verbose logging--ssl: A boolean flag to enable SSL/TLSThe parser should support both space-separated syntax (--port 3000) and equals syntax (--port=3000) for all arguments.
--config: A string specifying the path to a configuration file--host localhost --port 3000 returns an object with host "localhost" and port 3000 @test--port=8080 --verbose returns an object with port 8080 and verbose true @test--host=0.0.0.0 --port=443 --ssl returns an object with host "0.0.0.0", port 443, and ssl true @test--config=/path/to/config.json --verbose returns an object with config path and verbose true @test@generates
/**
* Parses command-line arguments for server configuration.
*
* @param {string[]} argv - Array of command-line arguments to parse
* @returns {Object} Parsed configuration object with properties:
* - host: string (optional)
* - port: number (optional)
* - verbose: boolean (optional)
* - config: string (optional)
* - ssl: boolean (optional)
* - _: array of positional arguments
*/
function parseServerConfig(argv) {
// IMPLEMENTATION HERE
}
module.exports = { parseServerConfig };Provides CLI argument parsing 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