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

CLI Task Manager Argument Parser

Build a command-line argument parser for a task management tool that handles various input formats and types.

@generates

Requirements

Create a parser that accepts the following command-line arguments:

  1. Task content flags:

    • --title: A string representing the task title (required for creating tasks)
    • --description or --desc: A string containing task description
    • --priority or -p: A number from 1-5 indicating task priority
    • --tags or -t: Can be specified multiple times to add multiple tags to a task
  2. Operation flags:

    • --verbose or -v: Can be specified multiple times to increase verbosity level (0-3)
    • --list or -l: A boolean flag to list all tasks
    • --complete or -c: A boolean flag to mark tasks as complete
    • --help or -h: A boolean flag to show help information
  3. Parsing behavior:

    • Unknown arguments should cause the parser to throw an error
    • Return a result object containing all parsed arguments
    • Collect any positional arguments (non-flag arguments) in the result

Test Cases

  • When parsing ['--title', 'Buy groceries', '--priority', '2'], the result contains a title string and priority number @test
  • When parsing ['-v', '-v', '-v'], the verbose flag value equals 3 @test
  • When parsing ['--tags', 'work', '--tags', 'urgent', '-t', 'important'], the tags array contains three strings @test
  • When parsing ['--desc', 'Task details'], the result contains the description under the canonical key name @test
  • When parsing ['--unknown', 'value'], an error is thrown @test

API

/**
 * Parse command-line arguments for the task manager
 * @param {string[]} argv - Array of argument strings to parse
 * @returns {Object} Parsed arguments with positional args in the _ property
 * @throws {Error} When unknown arguments are encountered
 */
function parseTaskArgs(argv) {
  // Implementation here
}

module.exports = { parseTaskArgs };

Dependencies { .dependencies }

arg { .dependency }

Provides command-line argument parsing capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-arg

tile.json