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

CLI Verbosity Configuration Parser

Build a command-line argument parser for a logging utility that supports multiple ways to specify verbosity levels through aliased argument names.

Requirements

Your parser should support the following verbosity configurations:

  1. A long-form argument --verbosity that accepts a number (0-3)
  2. A short-form argument -v that acts as an alias to --verbosity
  3. An alternative long-form --log-level that also aliases to --verbosity
  4. A debug argument -d that aliases to --log-level (which in turn aliases to --verbosity)

The parser should resolve all these aliases to a single canonical result key, regardless of which variant the user provides.

Input Format

The parser should accept command-line arguments as an array of strings (simulating process.argv.slice(2)).

Output Format

Return a parsed result object where:

  • The canonical key verbosity contains the resolved value
  • Positional arguments are collected in the _ array
  • Only the canonical name appears in results, not alias names

Test Cases

  • Parsing --verbosity 2 returns { verbosity: 2, _: [] } @test
  • Parsing -v 1 returns { verbosity: 1, _: [] } @test
  • Parsing --log-level 3 returns { verbosity: 3, _: [] } @test
  • Parsing -d 2 returns { verbosity: 2, _: [] } @test

@generates

/**
 * Parses command-line arguments with alias chain resolution
 *
 * @param {string[]} argv - Array of command-line arguments
 * @returns {Object} Parsed arguments with canonical names
 */
function parseArgs(argv) {
  // Implementation here
}

module.exports = { parseArgs };

Dependencies { .dependencies }

arg { .dependency }

Provides command-line argument parsing with alias support.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-arg

tile.json