mirror of
https://github.com/Cheviiot/Vintner.git
synced 2026-08-03 15:57:24 +00:00
vintner completion bash|zsh prints a completion script meant to be sourced (source <(vintner completion bash)); completes subcommands (including short aliases), download's flags, and directory arguments for install/env --bin. Mentioned in the top-level usage text and documented in the README. The Nivora package doesn't auto-install these system-wide yet - it'd need Stapler's install-completion helper, whose calling convention isn't documented anywhere in this repo or Nivora's other packages, so guessing at it risked a broken package build for a nice-to-have. source <(vintner completion bash) works today regardless of install method (Nivora, prebuilt binary, or from source).
68 lines
1.6 KiB
Go
68 lines
1.6 KiB
Go
// Command vintner cross compiles with the real MSVC toolchain on Linux
|
|
// via Wine. It's a multi-call binary that behaves as `cl`, `link`, `lib`,
|
|
// `rc`, `midl`, `mt`, `dumpbin`, `msbuild`, etc. when invoked under one of
|
|
// those names (via symlinks set up by `vintner install`), and
|
|
// otherwise exposes the `download`/`install`/`env`/`version` management
|
|
// subcommands.
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/Cheviiot/vintner/internal/i18n"
|
|
"github.com/Cheviiot/vintner/internal/wrapper"
|
|
)
|
|
|
|
// version is set at build time via -ldflags "-X main.version=X.Y.Z";
|
|
// left as "dev" for plain `go build`/`go run`.
|
|
var version = "dev"
|
|
|
|
func main() {
|
|
base := filepath.Base(os.Args[0])
|
|
name := strings.TrimSuffix(strings.ToLower(base), ".exe")
|
|
|
|
if _, ok := wrapper.Tools[name]; ok {
|
|
os.Exit(wrapper.Run(name, os.Args[1:]))
|
|
}
|
|
if name == "cmd" || name == "findstr" {
|
|
os.Exit(wrapper.Run(name, os.Args[1:]))
|
|
}
|
|
|
|
os.Exit(runCLI(os.Args[1:]))
|
|
}
|
|
|
|
func runCLI(args []string) int {
|
|
if len(args) == 0 {
|
|
printUsage()
|
|
return 1
|
|
}
|
|
|
|
switch args[0] {
|
|
case "download", "dl":
|
|
return runDownload(args[1:])
|
|
case "install", "i":
|
|
return runInstall(args[1:])
|
|
case "env", "e":
|
|
return runEnv(args[1:])
|
|
case "completion":
|
|
return runCompletion(args[1:])
|
|
case "version", "v", "--version":
|
|
fmt.Println("vintner " + version)
|
|
return 0
|
|
case "-h", "--help", "help", "h":
|
|
printUsage()
|
|
return 0
|
|
default:
|
|
fmt.Fprint(os.Stderr, i18n.T("main.unknown_subcommand", args[0]))
|
|
printUsage()
|
|
return 1
|
|
}
|
|
}
|
|
|
|
func printUsage() {
|
|
fmt.Fprint(os.Stderr, i18n.T("main.usage"))
|
|
}
|