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-9/

Configuration Value Parser

A command-line tool that parses numeric configuration values from command-line arguments. The tool should support various numeric inputs including integers, decimals, and negative numbers.

Capabilities

Parse integer port numbers

  • When the command-line includes --port 8080, the parser returns { port: 8080, _: [] } @test
  • When the command-line includes --port=3000, the parser returns { port: 3000, _: [] } @test

Parse decimal timeout values

  • When the command-line includes --timeout 2.5, the parser returns { timeout: 2.5, _: [] } @test
  • When the command-line includes --timeout=1.75, the parser returns { timeout: 1.75, _: [] } @test

Parse negative numeric values

  • When the command-line includes --temperature -5, the parser returns { temperature: -5, _: [] } @test
  • When the command-line includes --temperature=-15.5, the parser returns { temperature: -15.5, _: [] } @test

Handle multiple numeric arguments

  • When the command-line includes --port 8080 --timeout 2.5 --temperature -5, the parser returns { port: 8080, timeout: 2.5, temperature: -5, _: [] } @test

Implementation

@generates

API

/**
 * Parses command-line arguments and returns an object containing numeric configuration values.
 *
 * @param {string[]} args - Array of command-line arguments to parse
 * @returns {Object} Parsed result with numeric properties and a '_' array for positional arguments
 */
function parseConfig(args) {
  // IMPLEMENTATION HERE
}

module.exports = { parseConfig };

Dependencies { .dependencies }

arg { .dependency }

Provides command-line argument parsing support.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-arg

tile.json