     exit(0)
 }
 
+// MARK: - Argument handling
+
 let package = loadPackageFile()
 
 switch Process.arguments[1] {
 case "info":
     print("Dependencies:")
-    for dep in package.externals {
-        print("    \(dep.gitURL)")
-    }
-    exit(0)
+    if info(package) {
+        exit(0)
+    }
 case "fetch":
-    for pkg in package.externals {
-        print("Fetching external dependency \(pkg.name)...")
-        if fetchDependency(pkg) != true {
-            print("ERROR: Could not fetch \(pkg.name)")
-            exit(1)
-        }
-    }
-    exit(0)
+    if fetch(package) {
+        exit(0)
+    }
 case "update":
-    for pkg in package.externals {
-        print("Updating external dependency \(pkg.name)...")
-        if updateDependency(pkg) != true {
-            print("ERROR: Could not fetch \(pkg.name)")
-            exit(1)
-        }
-    }
-    exit(0)
+    if update(package) {
+        exit(0)
+    }
 case "add":
     print("not implemented")
 case "install":

    return updateDependency(pkg)
}

func help() {
    print("atpm - Anarchy Tools Package Manager \(version)")
    print("https://github.com/AnarchyTools")


    return package
}

// MARK: - Git stuff

func fetchVersions(pkg: ExternalDependency) -> [Version] {
    let fp = popen("cd external/\(pkg.name) && git tag -l *.*.* -l *.* -l v*.*.* -l v*.*", "r")
