CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-arg

Unopinionated, no-frills CLI argument parser for Node.js applications

Overall
score

99%

Overview
Eval results
Files

task.mdevals/scenario-10/

Configuration Parser

Build a command-line argument parser that processes server configuration options and returns a configuration object.

Requirements

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:

  • String values (server host, paths, API keys)
  • Numeric values (port numbers, sizes)
  • Boolean flags (HTTPS enable/disable)
  • Values containing special characters (dots, slashes, equals signs)

Capabilities

Parse Server Configuration

  • Parse --host=example.com and output {"host": "example.com"} @test
  • Parse --port=8080 and output {"port": 8080} @test
  • Parse --root=/var/www/html and output {"root": "/var/www/html"} @test

Parse Complex Path Values

  • Parse --log=/var/log/app.log and output {"log": "/var/log/app.log"} @test
  • Parse --root=/path/with/multiple/dirs and output {"root": "/path/with/multiple/dirs"} @test

Parse Numeric Configuration

  • Parse --max-size=100 and output {"maxSize": 100} @test
  • Parse --port=3000 --max-size=50 and output {"port": 3000, "maxSize": 50} @test

Parse String with Special Characters

  • Parse --api-key=abc123=def456 and output {"apiKey": "abc123=def456"} @test
  • Parse --host=api.example.com and output {"host": "api.example.com"} @test

Handle Boolean Flags

  • Parse --https and output {"https": true} @test
  • Parse --https --port=443 and output {"https": true, "port": 443} @test

Implementation

@generates

API

/**
 * 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 };

Dependencies { .dependencies }

arg { .dependency }

Provides command-line argument parsing with support for equals syntax.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-arg

tile.json