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

Temperature Monitor CLI

A command-line tool for recording and analyzing temperature readings from multiple sensors.

Capabilities

Parse temperature values

  • Accepts temperature values including negative numbers in both --temp=-5 and --temp -5 formats @test
  • Correctly distinguishes negative temperature values from CLI flags @test
  • Collects multiple temperature readings into an array @test

Parse sensor configuration

  • Accepts a sensor ID as a string value @test
  • Accepts boolean flags for enabling/disabling features @test

Requirements

The CLI should accept the following arguments:

  • --temp or -t: A temperature value (number). Can be specified multiple times to record multiple readings. Supports negative numbers (e.g., -10, -5.5).
  • --sensor: A sensor identifier (string).
  • --fahrenheit or -f: A boolean flag to indicate temperatures are in Fahrenheit (no value needed).
  • --verbose or -v: A boolean flag to enable verbose output (no value needed).

The tool should properly handle negative temperature values such as:

  • --temp=-10
  • --temp -10
  • -t -5.5

The parser should distinguish between negative numbers as values (like -10 for temperature) and actual CLI flags (like -f or -v).

Implementation

@generates

API

/**
 * Parses command-line arguments for the temperature monitor.
 *
 * @param {string[]} args - Array of command-line arguments
 * @returns {Object} Parsed arguments object with properties:
 *   - temp: number or number[] - Temperature value(s)
 *   - sensor: string - Sensor identifier
 *   - fahrenheit: boolean - Whether temps are in Fahrenheit
 *   - verbose: boolean - Whether to enable verbose output
 *   - _: string[] - Positional arguments
 */
function parseArgs(args) {
  // IMPLEMENTATION HERE
}

module.exports = { parseArgs };

Dependencies { .dependencies }

arg { .dependency }

Provides command-line argument parsing support.

Install with Tessl CLI

npx tessl i tessl/npm-arg

tile.json