baseline
This commit is contained in:
commit
52e7626a3e
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Specify only Windows architecture
|
||||||
|
ARCHITECTURES=("windows/amd64")
|
||||||
|
PROJECT_NAME=$(basename "$(pwd)")
|
||||||
|
|
||||||
|
prepare_build() {
|
||||||
|
mkdir -p dist build_logs
|
||||||
|
if [ ! -f go.mod ]; then
|
||||||
|
go mod init "$PROJECT_NAME"
|
||||||
|
fi
|
||||||
|
go mod tidy
|
||||||
|
}
|
||||||
|
|
||||||
|
build_binary() {
|
||||||
|
local os=$1
|
||||||
|
local arch=$2
|
||||||
|
local output="dist/${PROJECT_NAME}_${os}_${arch}.exe" # Note the .exe for Windows
|
||||||
|
env GOOS=$os GOARCH=$arch go build -o $output . &> "build_logs/${os}_${arch}.log"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Build failed for $os/$arch" >> "build_logs/error.log"
|
||||||
|
else
|
||||||
|
echo "Build succeeded for $os/$arch"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
prepare_build
|
||||||
|
for arch in "${ARCHITECTURES[@]}"; do
|
||||||
|
IFS="/" read -r os arch <<< "$arch"
|
||||||
|
build_binary $os $arch
|
||||||
|
done
|
||||||
|
echo "Build process completed."
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
Binary file not shown.
|
@ -0,0 +1,5 @@
|
||||||
|
module ae-send
|
||||||
|
|
||||||
|
go 1.21.1
|
||||||
|
|
||||||
|
require golang.org/x/sys v0.21.0
|
|
@ -0,0 +1,2 @@
|
||||||
|
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
||||||
|
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
@ -0,0 +1,72 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows/registry"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if len(os.Args) > 1 {
|
||||||
|
switch os.Args[1] {
|
||||||
|
case "install":
|
||||||
|
installContextMenuItem()
|
||||||
|
case "uninstall":
|
||||||
|
uninstallContextMenuItem()
|
||||||
|
default:
|
||||||
|
processFile(os.Args[1])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Println("No file provided")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func processFile(filePath string) {
|
||||||
|
log.Printf("Processing file: %s", filePath)
|
||||||
|
// Add your existing file processing logic here
|
||||||
|
}
|
||||||
|
|
||||||
|
func installContextMenuItem() {
|
||||||
|
keyPath := `Software\Classes\*\shell\AE Send`
|
||||||
|
commandPath := `Software\Classes\*\shell\AE Send\command`
|
||||||
|
|
||||||
|
k, _, err := registry.CreateKey(registry.CURRENT_USER, keyPath, registry.SET_VALUE)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to create registry key: %v", err)
|
||||||
|
}
|
||||||
|
defer k.Close()
|
||||||
|
|
||||||
|
err = k.SetStringValue("", "Send with AE Send")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to set registry value: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
exePath, err := os.Executable()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to get executable path: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
k, _, err = registry.CreateKey(registry.CURRENT_USER, commandPath, registry.SET_VALUE)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to create command registry key: %v", err)
|
||||||
|
}
|
||||||
|
defer k.Close()
|
||||||
|
|
||||||
|
err = k.SetStringValue("", "\""+exePath+"\" \"%1\"")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to set command: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("Context menu item installed successfully.")
|
||||||
|
}
|
||||||
|
|
||||||
|
func uninstallContextMenuItem() {
|
||||||
|
keyPath := `Software\Classes\*\shell\AE Send`
|
||||||
|
err := registry.DeleteKey(registry.CURRENT_USER, keyPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to remove context menu item: %v", err)
|
||||||
|
} else {
|
||||||
|
log.Println("Context menu item removed successfully.")
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
//go:build windows
|
||||||
|
// +build windows
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows/registry"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// Ensure we install and configure on first run
|
||||||
|
ensureInstallation()
|
||||||
|
ensureStartup()
|
||||||
|
}
|
||||||
|
|
||||||
|
func ensureInstallation() {
|
||||||
|
targetPath := filepath.Join(os.Getenv("ProgramFiles"), "AE-Send", "ae-send.exe")
|
||||||
|
currentPath, _ := os.Executable()
|
||||||
|
|
||||||
|
if currentPath != targetPath {
|
||||||
|
if err := os.MkdirAll(filepath.Dir(targetPath), 0755); err != nil {
|
||||||
|
return // handle error
|
||||||
|
}
|
||||||
|
if err := copyFile(currentPath, targetPath); err != nil {
|
||||||
|
return // handle error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Launch new instance
|
||||||
|
cmd := exec.Command(targetPath)
|
||||||
|
cmd.Start()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ensureStartup() {
|
||||||
|
key, _, err := registry.CreateKey(registry.CURRENT_USER, `Software\Microsoft\Windows\CurrentVersion\Run`, registry.SET_VALUE)
|
||||||
|
if err != nil {
|
||||||
|
return // handle error
|
||||||
|
}
|
||||||
|
defer key.Close()
|
||||||
|
|
||||||
|
currentPath, _ := os.Executable()
|
||||||
|
key.SetStringValue("AE-Send", currentPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func copyFile(src, dst string) error {
|
||||||
|
in, err := os.Open(src)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer in.Close()
|
||||||
|
|
||||||
|
out, err := os.Create(dst)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer out.Close()
|
||||||
|
|
||||||
|
_, err = io.Copy(out, in)
|
||||||
|
return err
|
||||||
|
}
|
Loading…
Reference in New Issue