mirror of
https://github.com/Cheviiot/Vintner.git
synced 2026-08-03 15:57:24 +00:00
Add short subcommand aliases and EN/RU CLI localization
Subcommands gain one/two-letter aliases (dl, i, e, v, h) alongside their full names. CLI-owned chrome - top-level usage, per-subcommand usage lines, progress messages, and the license prompt - now goes through internal/i18n, an env-driven message catalog (MSVC_GO_WINE_LANG, falling back to the standard LC_ALL/LC_MESSAGES/LANG locale variables) with English and Russian translations. Deeper error text from internal packages stays in English. Also refreshed the top-level usage text, which hadn't kept up with --with-wdk/--list-workloads/--list-components/--print-deps-tree.
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"runtime"
|
||||
|
||||
"github.com/Cheviiot/msvc-go-wine/internal/download"
|
||||
"github.com/Cheviiot/msvc-go-wine/internal/i18n"
|
||||
)
|
||||
|
||||
func runDownload(args []string) int {
|
||||
@@ -79,16 +80,16 @@ func runDownload(args []string) int {
|
||||
if opts.HostArch == "" {
|
||||
opts.HostArch = detectHostArch()
|
||||
}
|
||||
fmt.Println("Install packages for", opts.HostArch, "host architecture")
|
||||
fmt.Println(i18n.T("download.host_arch", opts.HostArch))
|
||||
|
||||
idx := download.BuildIndex(manifest, opts.HostArch, opts.Language)
|
||||
|
||||
if *listWorkloads || *listComponents {
|
||||
if *listWorkloads {
|
||||
printPackageList("Workload", download.PackagesByType(idx, "Workload"), opts.Language)
|
||||
printPackageList("download.workloads_header", download.PackagesByType(idx, "Workload"), opts.Language)
|
||||
}
|
||||
if *listComponents {
|
||||
printPackageList("Component", download.PackagesByType(idx, "Component"), opts.Language)
|
||||
printPackageList("download.components_header", download.PackagesByType(idx, "Component"), opts.Language)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -123,8 +124,8 @@ func runDownload(args []string) int {
|
||||
downloadSize += p.DownloadSize()
|
||||
installSize += p.InstalledSize()
|
||||
}
|
||||
fmt.Printf("Selected %d packages, for a total download size of %s, install size of %s\n",
|
||||
len(selected), download.HumanizeBytes(downloadSize), download.HumanizeBytes(installSize))
|
||||
fmt.Print(i18n.T("download.selected",
|
||||
len(selected), download.HumanizeBytes(downloadSize), download.HumanizeBytes(installSize)))
|
||||
|
||||
cache := *cacheDir
|
||||
removeCache := false
|
||||
@@ -148,7 +149,7 @@ func runDownload(args []string) int {
|
||||
return 1
|
||||
}
|
||||
*dest = def
|
||||
fmt.Println("--dest not set, using default:", *dest)
|
||||
fmt.Println(i18n.T("download.default_dest", *dest))
|
||||
}
|
||||
|
||||
if err := download.FetchPayloads(selected, cache, *onlyDownload); err != nil {
|
||||
@@ -207,7 +208,7 @@ func runDownload(args []string) int {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Done. Next: msvc-go-wine install", destAbs)
|
||||
fmt.Println(i18n.T("download.done", destAbs))
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -226,7 +227,7 @@ func downloadWDK(opts *download.Options, selected []*download.Package, cache, de
|
||||
}
|
||||
}
|
||||
if len(archs) == 0 {
|
||||
fmt.Println("--with-wdk: no x64/arm64 target architecture selected, skipping (no WDK package exists for x86/arm)")
|
||||
fmt.Println(i18n.T("download.wdk_skip"))
|
||||
return nil
|
||||
}
|
||||
for _, arch := range archs {
|
||||
@@ -238,7 +239,7 @@ func downloadWDK(opts *download.Options, selected []*download.Package, cache, de
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Installed WDK (%s) %s at %s\n", arch, version, wdkDir)
|
||||
fmt.Print(i18n.T("download.wdk_installed", arch, version, wdkDir))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -254,8 +255,9 @@ func contains(list []string, v string) bool {
|
||||
|
||||
// printPackageList prints one line per package: its ID, and (when the
|
||||
// manifest carries one) its human-readable title in the requested language.
|
||||
func printPackageList(kind string, pkgs []*download.Package, language string) {
|
||||
fmt.Printf("Available %ss (%d):\n", kind, len(pkgs))
|
||||
// headerKey is an i18n catalog key taking the package count as its one arg.
|
||||
func printPackageList(headerKey string, pkgs []*download.Package, language string) {
|
||||
fmt.Print(i18n.T(headerKey, len(pkgs)))
|
||||
for _, p := range pkgs {
|
||||
if lr := p.Localized(language); lr != nil && lr.Title != "" {
|
||||
fmt.Printf(" %-65s %s\n", p.ID, lr.Title)
|
||||
@@ -273,7 +275,7 @@ func detectHostArch() string {
|
||||
}
|
||||
|
||||
func promptAcceptLicense(license string) bool {
|
||||
fmt.Printf("Do you accept the license at %s (yes/no)? ", license)
|
||||
fmt.Print(i18n.T("download.license_prompt", license))
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
for scanner.Scan() {
|
||||
switch scanner.Text() {
|
||||
@@ -282,7 +284,7 @@ func promptAcceptLicense(license string) bool {
|
||||
case "no":
|
||||
return false
|
||||
}
|
||||
fmt.Print("Do you accept the license? Answer \"yes\" or \"no\": ")
|
||||
fmt.Print(i18n.T("download.license_reprompt"))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/Cheviiot/msvc-go-wine/internal/i18n"
|
||||
"github.com/Cheviiot/msvc-go-wine/internal/wineenv"
|
||||
)
|
||||
|
||||
@@ -20,7 +21,7 @@ func runEnv(args []string) int {
|
||||
return 2
|
||||
}
|
||||
if *bin == "" {
|
||||
fmt.Fprintln(os.Stderr, "usage: msvc-go-wine env --bin <dest>/bin/<arch>")
|
||||
fmt.Fprintln(os.Stderr, i18n.T("env.usage"))
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ func runEnv(args []string) int {
|
||||
|
||||
triple, ok := targetTriples[cfg.Arch]
|
||||
if !ok {
|
||||
fmt.Fprintf(os.Stderr, "msvc-go-wine env: unknown arch %q\n", cfg.Arch)
|
||||
fmt.Fprint(os.Stderr, i18n.T("env.unknown_arch", cfg.Arch))
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,13 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/Cheviiot/msvc-go-wine/internal/i18n"
|
||||
"github.com/Cheviiot/msvc-go-wine/internal/install"
|
||||
)
|
||||
|
||||
func runInstall(args []string) int {
|
||||
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)")
|
||||
fmt.Fprintln(os.Stderr, i18n.T("install.usage"))
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -23,7 +24,7 @@ func runInstall(args []string) int {
|
||||
return 1
|
||||
}
|
||||
dest = def
|
||||
fmt.Println("No directory given, using default:", dest)
|
||||
fmt.Println(i18n.T("install.default_dir", dest))
|
||||
}
|
||||
|
||||
self, err := os.Executable()
|
||||
@@ -36,6 +37,6 @@ func runInstall(args []string) int {
|
||||
fmt.Fprintln(os.Stderr, "msvc-go-wine install:", err)
|
||||
return 1
|
||||
}
|
||||
fmt.Println("Done. Add", dest+"/bin/<arch> to PATH to use cl, link, lib, ...")
|
||||
fmt.Println(i18n.T("install.done", dest+"/bin/<arch>"))
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/Cheviiot/msvc-go-wine/internal/i18n"
|
||||
"github.com/Cheviiot/msvc-go-wine/internal/wrapper"
|
||||
)
|
||||
|
||||
@@ -40,38 +41,25 @@ func runCLI(args []string) int {
|
||||
}
|
||||
|
||||
switch args[0] {
|
||||
case "download":
|
||||
case "download", "dl":
|
||||
return runDownload(args[1:])
|
||||
case "install":
|
||||
case "install", "i":
|
||||
return runInstall(args[1:])
|
||||
case "env":
|
||||
case "env", "e":
|
||||
return runEnv(args[1:])
|
||||
case "version":
|
||||
case "version", "v", "--version":
|
||||
fmt.Println("msvc-go-wine " + version)
|
||||
return 0
|
||||
case "-h", "--help", "help":
|
||||
case "-h", "--help", "help", "h":
|
||||
printUsage()
|
||||
return 0
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "msvc-go-wine: unknown subcommand %q\n\n", args[0])
|
||||
fmt.Fprint(os.Stderr, i18n.T("main.unknown_subcommand", args[0]))
|
||||
printUsage()
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
func printUsage() {
|
||||
fmt.Fprint(os.Stderr, `msvc-go-wine - cross compile with MSVC on Linux via Wine
|
||||
|
||||
Usage:
|
||||
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
|
||||
`)
|
||||
fmt.Fprint(os.Stderr, i18n.T("main.usage"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user