## Learning Nim Types for NexusOS Package Management
## This demonstrates object, enum, and seq types

import std/strformat

echo "=== Learning Nim Types for NexusOS ==="

# Example 1: Enum for package streams
type
  PackageStream* = enum
    Stable = "stable"
    Testing = "testing"
    Dev = "dev"
    LTS = "lts"

echo "\n1. Package Streams (enum):"
let stream1 = Stable
let stream2 = Testing
echo fmt"Stream 1: {stream1}, Stream 2: {stream2}"

# Example 2: Object for package metadata
type
  PackageId* = object
    name*: string
    version*: string
    stream*: PackageStream

echo "\n2. Package Objects:"
let pkg1 = PackageId(name: "neofetch", version: "7.1.0", stream: Stable)
let pkg2 = PackageId(name: "htop", version: "3.2.1", stream: Testing)
echo fmt"Package 1: {pkg1.name}-{pkg1.version} [{pkg1.stream}]"
echo fmt"Package 2: {pkg2.name}-{pkg2.version} [{pkg2.stream}]"

# Example 3: Sequences (dynamic arrays)
echo "\n3. Package Collections (seq):"
var packages: seq[PackageId] = @[]
packages.add(pkg1)
packages.add(pkg2)
packages.add(PackageId(name: "vim", version: "9.0", stream: LTS))

echo fmt"Total packages: {packages.len}"
for i, pkg in packages:
  echo fmt"  {i+1}. {pkg.name}-{pkg.version} [{pkg.stream}]"

# Example 4: String formatting with $
proc `$`*(pkg: PackageId): string =
  fmt"{pkg.name}-{pkg.version}[{pkg.stream}]"

echo "\n4. Custom string formatting:"
for pkg in packages:
  echo fmt"Package: {pkg}"

echo "\n=== Key Takeaways ==="
echo "- enum: Fixed options (Stable, Testing, etc.)"
echo "- object: Structured data (name, version, stream)"
echo "- seq: Dynamic lists for collections"
echo "- proc `$`: Custom string representation"