-
Notifications
You must be signed in to change notification settings - Fork 0
/
minstall.ps1
56 lines (51 loc) · 1.53 KB
/
minstall.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function Default-Config {
Set-Location ~
New-Item -Path '~/.mincfg' -ItemType File
Set-Content -Path '.mincfg' -Value "~/Desktop"
}
function Get-Help-Flag {
Write-Host "Script that allows you to download any Mindustry version. Flags:`n`t -p - change download path and run`n`t -h - display this message`n`t -d - display download path`nUsage:`n`t./minstall.sh -p [yourpathhere]`n"
}
function Display-Flag {
Set-Location ~
$a = Get-Content -Path ".mincfg"
Write-Host "Recent location: `n`t$a"
}
function Get-Mindustry {
Set-Location ~
Write-Host "Mindustry version: "
$Version = Read-Host
$path = (Get-Content -Path ".mincfg")
Set-Location $path
Invoke-WebRequest "https://github.com/Anuken/Mindustry/releases/download/v$Version/Mindustry.jar"
$loc = Get-Location
Write-Host "Downloaded mindustry $Version at $loc"
}
if ($args.Length -eq 0) {
Get-Help-Flag
}
foreach ($i in $args) {
if (!(Test-Path "~/.mincfg")) {
Default-Config
}
switch ($i.ToLower()) {
{($_ -eq "-h") -or ($_ -eq "--help")} {
Get-Help-Flag
Return
}
{($_ -eq "-d") -or ($_ -eq "--display")} {
Display-Flag
Return
}
{($_ -eq "-p") -or ($_ -eq "--path")} {
$wr = $args[$args.Length - 1]
Set-Location ~/
Set-Location $wr
$loc = Get-Location
Set-Content -Path "~/.mincfg" -Value $loc
Get-Mindustry
Return
}
}
Get-Mindustry
}