Skip to content

Instantly share code, notes, and snippets.

@Yanrishatum
Created July 12, 2018 19:07
Show Gist options
  • Save Yanrishatum/bec89c12982a4e438f874fa8f044b4d7 to your computer and use it in GitHub Desktop.
Save Yanrishatum/bec89c12982a4e438f874fa8f044b4d7 to your computer and use it in GitHub Desktop.
var what = requestArgument("Haxe or Hashlink? [HAXE/hl]: ");
if (what.toLowerCase() != "hl") what = "haxe";
else what = "hl";
var currFile = "haxe_ver/." + what + "_current";
var dir = sys.FileSystem.readDirectory("haxe_ver");
var current = sys.FileSystem.exists(currFile) ? sys.io.File.getContent(currFile) : "";
var versions = [];
for (name in dir)
{
if (name.charAt(0) == ".") continue;
if (StringTools.startsWith(name, what))
{
var idx = versions.push(name);
if (name == current) name = "[" + name + "]";
Sys.println(idx + ": " + name);
}
}
Sys.print("Select version: ");
var char = Sys.stdin().readLine();
if (char != "")
{
char = Std.parseInt(char) - 1;
if (char >= 0 && char < versions.length)
{
Sys.println("Setting new version to: " + versions[char]);
if (sys.FileSystem.exists(what)) Sys.command("rm", [what]);
Sys.command("mklink", ["/d", what, "haxe_ver\\" + versions[char]]);
sys.io.File.saveContent(currFile, versions[char]);
}
else Sys.println("Invalid index!");
}
else Sys.println("No changes were made");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment