Skip to content

Commit e067883

Browse files
committed
feat: add PowerShell install script for Windows
- Add install.ps1 for native Windows installation experience - Fix incomplete Windows instructions in README (missing directory creation and PATH configuration) - Add Windows build instructions to Developer Quick Start section Closes #806
1 parent 71b3a5d commit e067883

File tree

2 files changed

+136
-2
lines changed

2 files changed

+136
-2
lines changed

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
Want to contribute or build from source?
2626

27+
**macOS/Linux:**
2728
```bash
2829
# Clone the repository
2930
git clone https://github.com/SchoolyB/EZ.git
@@ -36,6 +37,19 @@ make build
3637
./ez examples/hello.ez
3738
```
3839

40+
**Windows (PowerShell):**
41+
```powershell
42+
# Clone the repository
43+
git clone https://github.com/SchoolyB/EZ.git
44+
cd EZ
45+
46+
# Build the binary
47+
go build -o ez.exe ./cmd/ez
48+
49+
# Run a program
50+
.\ez.exe examples\hello.ez
51+
```
52+
3953
**Requirements:** Go 1.23.1 or higher
4054

4155
For pre-built binaries and installation instructions, visit the [documentation](https://schoolyb.github.io/language.ez/docs).
@@ -82,8 +96,22 @@ Invoke-WebRequest -Uri "https://github.com/SchoolyB/EZ/releases/latest/download/
8296
Expand-Archive ez.zip -DestinationPath .
8397
Remove-Item ez.zip
8498
85-
# Move to a directory in your PATH (e.g., C:\Program Files\ez)
86-
Move-Item ez.exe "C:\Program Files\ez\ez.exe"
99+
# Create install directory and move binary
100+
New-Item -ItemType Directory -Path "$env:ProgramFiles\ez" -Force
101+
Move-Item ez.exe "$env:ProgramFiles\ez\ez.exe" -Force
102+
103+
# Add to PATH (if not already present)
104+
$path = [Environment]::GetEnvironmentVariable("Path", "Machine")
105+
if ($path -notlike "*$env:ProgramFiles\ez*") {
106+
[Environment]::SetEnvironmentVariable("Path", "$path;$env:ProgramFiles\ez", "Machine")
107+
Write-Host "Added to PATH - restart your terminal for changes to take effect"
108+
}
109+
```
110+
111+
Alternatively, if building from source, you can use the install script:
112+
```powershell
113+
# Run as Administrator for system-wide install, or as regular user for user-local install
114+
.\install.ps1
87115
```
88116

89117
After this one-time manual update, `ez update` will work automatically for all future versions.

install.ps1

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# EZ Language Installer for Windows
2+
#
3+
# Copyright (c) 2025-Present Marshall A Burns
4+
# Licensed under the MIT License. See LICENSE for details.
5+
#
6+
# Run as Administrator for system-wide installation,
7+
# or as regular user for user-local installation.
8+
9+
$ErrorActionPreference = "Stop"
10+
11+
Write-Host "EZ Language Installer" -ForegroundColor Cyan
12+
Write-Host "====================" -ForegroundColor Cyan
13+
Write-Host ""
14+
15+
# Check if running as Administrator
16+
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
17+
18+
if ($isAdmin) {
19+
$InstallDir = "$env:ProgramFiles\ez"
20+
$PathScope = "Machine"
21+
Write-Host "Running as Administrator - installing system-wide" -ForegroundColor Green
22+
} else {
23+
$InstallDir = "$env:LOCALAPPDATA\ez"
24+
$PathScope = "User"
25+
Write-Host "Running as regular user - installing for current user only" -ForegroundColor Yellow
26+
Write-Host "(Run as Administrator for system-wide installation)" -ForegroundColor Gray
27+
}
28+
29+
Write-Host ""
30+
31+
# Check if Go is installed
32+
try {
33+
$goVersion = go version
34+
Write-Host "Found: $goVersion" -ForegroundColor Green
35+
} catch {
36+
Write-Host "Error: Go is not installed" -ForegroundColor Red
37+
Write-Host "Please install Go from https://golang.org/dl/" -ForegroundColor Yellow
38+
exit 1
39+
}
40+
41+
# Build the binary
42+
Write-Host ""
43+
Write-Host "Building EZ..." -ForegroundColor Cyan
44+
try {
45+
go build -o ez.exe ./cmd/ez
46+
if (-not (Test-Path "ez.exe")) {
47+
throw "Build failed - ez.exe not created"
48+
}
49+
Write-Host "Build successful" -ForegroundColor Green
50+
} catch {
51+
Write-Host "Error: Build failed" -ForegroundColor Red
52+
Write-Host $_.Exception.Message -ForegroundColor Red
53+
exit 1
54+
}
55+
56+
# Create install directory
57+
Write-Host ""
58+
Write-Host "Installing to $InstallDir..." -ForegroundColor Cyan
59+
try {
60+
if (-not (Test-Path $InstallDir)) {
61+
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
62+
Write-Host "Created directory: $InstallDir" -ForegroundColor Green
63+
}
64+
65+
# Move binary to install directory
66+
Move-Item -Path "ez.exe" -Destination "$InstallDir\ez.exe" -Force
67+
Write-Host "Installed ez.exe to $InstallDir" -ForegroundColor Green
68+
} catch {
69+
Write-Host "Error: Failed to install" -ForegroundColor Red
70+
Write-Host $_.Exception.Message -ForegroundColor Red
71+
# Clean up local binary if it exists
72+
if (Test-Path "ez.exe") { Remove-Item "ez.exe" -Force }
73+
exit 1
74+
}
75+
76+
# Add to PATH if not already present
77+
$currentPath = [Environment]::GetEnvironmentVariable("Path", $PathScope)
78+
if ($currentPath -notlike "*$InstallDir*") {
79+
Write-Host ""
80+
Write-Host "Adding $InstallDir to PATH..." -ForegroundColor Cyan
81+
try {
82+
$newPath = "$currentPath;$InstallDir"
83+
[Environment]::SetEnvironmentVariable("Path", $newPath, $PathScope)
84+
Write-Host "Added to $PathScope PATH" -ForegroundColor Green
85+
Write-Host "Note: Restart your terminal for PATH changes to take effect" -ForegroundColor Yellow
86+
} catch {
87+
Write-Host "Warning: Could not add to PATH automatically" -ForegroundColor Yellow
88+
Write-Host "Please add '$InstallDir' to your PATH manually" -ForegroundColor Yellow
89+
}
90+
} else {
91+
Write-Host "$InstallDir is already in PATH" -ForegroundColor Green
92+
}
93+
94+
Write-Host ""
95+
Write-Host "========================================" -ForegroundColor Cyan
96+
Write-Host "EZ installed successfully!" -ForegroundColor Green
97+
Write-Host "========================================" -ForegroundColor Cyan
98+
Write-Host ""
99+
Write-Host "Run 'ez <file>' to execute EZ programs" -ForegroundColor White
100+
Write-Host ""
101+
Write-Host "To uninstall, run:" -ForegroundColor Gray
102+
Write-Host " Remove-Item -Recurse -Force '$InstallDir'" -ForegroundColor Gray
103+
if ($PathScope -eq "Machine") {
104+
Write-Host " (Run as Administrator)" -ForegroundColor Gray
105+
}
106+
Write-Host ""

0 commit comments

Comments
 (0)