import strutils, os

type
  Source* = object
    url*: string
    blake3*: string
  Fragment* = object
    name*: string
    version*: string
    source*: Source
    dependencies*: seq[string]
  NexusRecipe* = Fragment

proc translateNixFlake(flakeUrl: string): NexusRecipe =
  echo "Translating Nix Flake: ", flakeUrl
  result = NexusRecipe(
    name: "example",
    version: "1.0.0",
    source: Source(url: flakeUrl, blake3: ""),
    dependencies: @[]
  )

proc translateAUR(pkgbuildUrl: string): NexusRecipe =
  echo "Translating AUR PKGBUILD: ", pkgbuildUrl
  result = NexusRecipe(
    name: "example",
    version: "1.0.0",
    source: Source(url: pkgbuildUrl, blake3: ""),
    dependencies: @[]
  )

proc getRecipe(source, url: string, iKnowWhatIDo: bool): NexusRecipe =
  if not iKnowWhatIDo:
    quit("Error: --i-know-what-i-do flag required for external sources")
  case source
  of "nixpkgs":
    result = translateNixFlake(url)
  of "aur":
    result = translateAUR(url)
  else:
    quit("Unknown source: " & source)
