πŸ† Final Project: Wiki Explorer Pro

⏱ 2-3 hours πŸ“Š Advanced 🎯 Capstone

Build a Complete Wikipedia CLI Application

This capstone project combines every concept from the course into a single, production‑ready command‑line tool. You'll create a multi‑package workspace with a polished CLI, robust error handling, structured logging, and unit tests.

🎯 Project Overview

Create a CLI tool called Wiki Explorer Pro that allows users to:

  • Search Wikipedia articles and display results with URLs
  • Get a summary of any article by title
  • View article extracts in plain text or HTML
  • Compare two articles side‑by‑side
  • Export search results or summaries to a JSON file
  • Log all requests and errors to daily log files
  • Run in interactive mode with a menu, or accept direct commands
πŸ—οΈ Architecture Requirements

Your project must use a multi‑package workspace with at least three packages:

  1. command_runner – A reusable CLI framework (commands, arguments, help)
  2. wikipedia – API client with model classes and JSON parsing
  3. cli – The main application entry point and concrete commands

Each package should have its own pubspec.yaml and be linked via a root workspace.

πŸ“‹ Detailed Requirements

1. Command Runner Package

  • Abstract Command class with name, description, run()
  • Support for flags and options (e.g., --verbose, --output)
  • Built‑in HelpCommand that displays usage for all commands
  • Custom ArgumentException for invalid user input
  • CommandRunner class that parses input and dispatches commands

2. Wikipedia Package

  • Model classes: SearchResult, ArticleSummary, Article
  • Use pattern matching in fromJson() factories
  • Methods: search(), getSummary(), getArticle()
  • Simulated API calls with realistic delays (use Future.delayed)
  • Throw custom exceptions (ArticleNotFoundException, ApiException)

3. CLI Application

  • Commands: search, summary, compare, export
  • Interactive mode when no arguments given (menu loop)
  • Accept command‑line arguments for direct execution
  • Logging: create a logger that writes to logs/YYYY_MM_DD_wiki.log
  • Log all searches, errors, and API response times
  • Graceful error handling with user‑friendly messages

4. Testing

  • Unit tests for Wikipedia model classes (valid JSON, invalid JSON, missing fields)
  • Tests for CommandRunner argument parsing
  • At least 10 test cases total

πŸ“Ί Expected Behavior

Terminal (Direct Mode)
$ dart run bin/cli.dart search Dart programming
πŸ” Searching for "Dart programming"...
1. Dart (programming language) - https://en.wikipedia.org/wiki/Dart_(programming_language)
2. Dartmoor - https://en.wikipedia.org/wiki/Dartmoor
3. Dartford - https://en.wikipedia.org/wiki/Dartford
βœ… Search completed in 1.2s

$ dart run bin/cli.dart summary Dart
πŸ“– Dart (programming language)
──────────────────────────────────────
Dart is a programming language designed by Lars Bak and Kasper Lund and developed by Google. It can be used to develop web and mobile apps as well as server and desktop applications.
──────────────────────────────────────
πŸ”— https://en.wikipedia.org/wiki/Dart_(programming_language)

$ dart run bin/cli.dart compare Dart Flutter
πŸ“Š Comparing Articles
──────────────────────────────────────
Dart                | Flutter
──────────────────────────────────────
Programming language | UI toolkit
Developed by Google  | Developed by Google
First appeared 2011  | First appeared 2017
──────────────────────────────────────
πŸ”’ Click to reveal the complete solution (build it yourself first!)
name: _ publish_to: none environment: sdk: ^3.12.0 workspace: - cli - command_runner - wikipedia name: command_runner description: A reusable CLI command framework. version: 1.0.0 resolution: workspace environment: sdk: ^3.12.0 library command_runner; export 'src/command.dart'; export 'src/command_runner_base.dart'; export 'src/exceptions.dart'; abstract class Command { final String name; final String description; final List