SwiftbeginnercliAI generated

Command-Line Unit and Currency Converter

Write a Swift command-line tool that converts between metric/imperial units and fetches live exchange rates for currency conversion from a public API. Learners practice Swift scripting, URLSession with async/await, and argument parsing.

Estimate
~8h
Steps
6
Completed by
0
Proposed by
codeseed.app

Foundation · URLSession

Project roadmap

  1. 01

    Set up a Swift executable package

    ~1h

    Create a Swift package with an executable target for the CLI tool.

  2. 02

    Implement unit conversion functions

    ~1.5h

    Write functions converting between metric and imperial length, weight, and volume units.

  3. 03

    Parse command-line arguments

    ~1.5h

    Read the conversion type and value from command-line arguments.

  4. 04

    Fetch live exchange rates

    ~2h

    Use async/await with URLSession to fetch current exchange rates from a public API.

  5. 05

    Format and print results

    ~1h

    Print conversion results with appropriate rounding and unit labels.

  6. 06

    Handle network errors

    ~1h

    Gracefully handle network failures and invalid API responses.

Resources

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~8h · 6 steps

Tech stack

FoundationURLSession