Default download/install to ~/.msvc-go-wine when no dir is given

--dest (download) and the positional dir (install) were previously
required, forcing every user to pick and remember a location. Both now
default to a single hidden ~/.msvc-go-wine, matching the convention most
CLI tools use for their own data dir - still overridable for anyone who
wants a different location.
This commit is contained in:
Cheviiot
2026-07-25 01:38:47 +10:00
parent 7ce6316b0a
commit 8f52e5861a
5 changed files with 58 additions and 18 deletions
+8 -3
View File
@@ -13,7 +13,7 @@ import (
func runDownload(args []string) int {
fs := flag.NewFlagSet("download", flag.ContinueOnError)
dest := fs.String("dest", "", "directory to install into (required unless --only-download)")
dest := fs.String("dest", "", "directory to install into (default: ~/.msvc-go-wine)")
cacheDir := fs.String("cache", "", "directory to use as a persistent download cache (default: a temp dir, removed afterwards)")
major := fs.Int("major", 18, "the major VS version to download")
preview := fs.Bool("preview", false, "download the preview/insiders channel instead of release/stable")
@@ -122,8 +122,13 @@ func runDownload(args []string) int {
}
if !*onlyDownload && *dest == "" {
fmt.Fprintln(os.Stderr, "msvc-go-wine download: --dest is required unless --only-download is set")
return 1
def, err := defaultToolchainDir()
if err != nil {
fmt.Fprintln(os.Stderr, "msvc-go-wine download:", err)
return 1
}
*dest = def
fmt.Println("--dest not set, using default:", *dest)
}
if err := download.FetchPayloads(selected, cache, *onlyDownload); err != nil {
+15 -3
View File
@@ -8,11 +8,23 @@ import (
)
func runInstall(args []string) int {
if len(args) != 1 || args[0] == "-h" || args[0] == "--help" {
fmt.Fprintln(os.Stderr, "usage: msvc-go-wine install <dest>")
if len(args) > 1 || (len(args) == 1 && (args[0] == "-h" || args[0] == "--help")) {
fmt.Fprintln(os.Stderr, "usage: msvc-go-wine install [dest] (default: ~/.msvc-go-wine)")
return 1
}
dest := args[0]
var dest string
if len(args) == 1 {
dest = args[0]
} else {
def, err := defaultToolchainDir()
if err != nil {
fmt.Fprintln(os.Stderr, "msvc-go-wine install:", err)
return 1
}
dest = def
fmt.Println("No directory given, using default:", dest)
}
self, err := os.Executable()
if err != nil {
+5 -2
View File
@@ -63,11 +63,14 @@ func printUsage() {
fmt.Fprint(os.Stderr, `msvc-go-wine - cross compile with MSVC on Linux via Wine
Usage:
msvc-go-wine download --dest <dir> [options] fetch and unpack MSVC/WinSDK
msvc-go-wine install <dir> wire up wrappers for a downloaded MSVC
msvc-go-wine download --accept-license [--dest <dir>] [options]
fetch and unpack MSVC/WinSDK
msvc-go-wine install [dir] wire up wrappers for a downloaded MSVC
msvc-go-wine env --bin <dir/bin/arch> print INCLUDE/LIB for native clang-cl/lld-link use
msvc-go-wine version print the version
--dest/[dir] default to ~/.msvc-go-wine if omitted.
Once installed, add <dir>/bin/<arch> to PATH and invoke the tools directly:
cl, link, lib, ml, ml64, mc, midl, mt, rc, dumpbin, msbuild, nmake, armasm, armasm64, cmd, findstr
`)
+17
View File
@@ -0,0 +1,17 @@
package main
import (
"os"
"path/filepath"
)
// defaultToolchainDir is where `download`/`install` operate when the user
// doesn't specify a directory: a hidden ~/.msvc-go-wine, so it doesn't
// clutter a plain `ls ~`.
func defaultToolchainDir() (string, error) {
home, err := os.UserHomeDir()
if err != nil {
return "", err
}
return filepath.Join(home, ".msvc-go-wine"), nil
}