Unopinionated, no-frills CLI argument parser for Node.js applications
Overall
score
99%
A command-line tool for recording and analyzing temperature readings from multiple sensors.
--temp=-5 and --temp -5 formats @testThe 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.5The parser should distinguish between negative numbers as values (like -10 for temperature) and actual CLI flags (like -f or -v).
@generates
/**
* 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 };Provides command-line argument parsing support.
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