Skip to main content

CLI Unit Convertor

This project moves you from arithmetic execution
to structured transformation systems.

You are no longer applying operators.

You are building:

  • A conversion engine
  • A validation layer
  • A category-based dispatch system
  • A CLI interaction loop
  • A floating-point safe output formatter

This is closer to real software than a calculator.

Why This Project Exists

A unit converter forces you to reason about:

  • Structured mappings (dictionary design)
  • Dynamic dispatch
  • Validation logic
  • String normalization
  • Floating-point precision
  • Defensive programming
  • Extensibility design

You will build a system that converts between:

  • Length
  • Mass
  • Temperature
  • Time
  • Speed

Without using external libraries.

System Architecture

Your CLI should follow this structure:

  1. CLI Loop
  2. Command Parsing
  3. Category Validation
  4. Unit Validation
  5. Numeric Parsing
  6. Conversion Engine
  7. Output Formatting
  8. Error Handling

No step should be skipped.

Step 1 - Define the Conversion Model

The correct architecture is:

All units convert to a base unit.

Example (Length):

  • Base: meters
  • km → multiply by 1000
  • cm → multiply by 0.01
  • mi → multiply by 1609.34

Structure:

CONVERSIONS = {
"length": {
"base": "m",
"units": {
"m": lambda x: x,
"km": lambda x: x * 1000,
"cm": lambda x: x * 0.01,
"mm": lambda x: x * 0.001,
"mi": lambda x: x * 1609.34,
}
}
}
© 2026 EngineersOfAI. All rights reserved.