             }
 
             do {
-                try run("chmod +x \(name)")
-                try run("mv \(name) \(directory)")
-            } catch {
-                print("Trying with sudo...")
-                do {
-                    try run("sudo mv \(name) \(directory)")
-                } catch {
-                    fail("Could not move Vapor CLI to install location.")
-                }
-            }
-
-            do {
-                try run("rm \(source)")
+                try SelfCommands.install(from: name, to: target)
+            } catch {
+                fail("Could not install compiled binary at '\(target)'")
+            }
+
+            do {
+                try run("rm \(tmp)")
             } catch {
 
             }

            }

            do {
                try run("chmod +x \(name)")
                try run("./\(name) self install")
            } catch {
                fail("Could not update CLI.")
            }
        }

        static var help: [String] {
            return [
                "Downloads the latest version of",
                "the Vapor command line interface."
            ]
        }
    }


var iterator = Process.arguments.makeIterator()

// FIXME: Sven: this is actually the path to the binary, not the directory
// not sure why this is called directory, perhaps this used to be run through `dirname`?
guard let directory = iterator.next() else {
    fail("no directory")
}
