or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-2/

File Converter CLI

Build a command-line tool that converts files between different text formats with configurable options.

Requirements

Your task is to create a CLI application that accepts various command-line options and processes files based on those options. The tool should support the following functionality:

  1. File Input/Output: Accept an input file path and an output file path
  2. Format Conversion: Support conversion between formats (uppercase, lowercase, title case)
  3. Line Numbering: Optionally add line numbers to the output
  4. Encoding: Allow specifying the text encoding (default: utf8)
  5. Verbose Mode: Display processing information when enabled

Command-Line Options

Your application must support the following command-line options:

  • Input file specification (required)
  • Output file specification (required)
  • Format conversion type (one of: uppercase, lowercase, titlecase)
  • Line numbering flag (boolean)
  • Text encoding (string with default value)
  • Verbose mode flag (boolean)

Each option should have both a short form (single letter with -) and a long form (full word with --).

Behavior

  • If required options are missing, display an error message
  • If the input file doesn't exist, display an error message
  • Read the input file and apply the specified transformations
  • Write the result to the output file
  • In verbose mode, print status messages about the processing steps

Test Cases

  • Given input file "hello.txt" with content "hello world", format uppercase, output should contain "HELLO WORLD" @test
  • Given input file with content "LOUD TEXT", format lowercase, output should contain "loud text" @test
  • Given line numbering enabled and input "line one\nline two", output should contain numbered lines @test
  • Missing required input file option should display an error @test

@generates

API

/**
 * Main CLI application entry point
 * Parses command-line arguments and processes file conversion
 */
function main() {
  // Parse command-line options
  // Validate required options
  // Read input file
  // Apply transformations
  // Write output file
}

module.exports = { main };

Dependencies { .dependencies }

cli { .dependency }

Provides command-line argument parsing with support for defining options with short and long names, type validation, and default values.

@satisfied-by