Files
tia-love/cmd/tia/main.go
T

72 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"fmt"
"os"
"runtime/debug"
tea "charm.land/bubbletea/v2"
"github.com/oxpoe/tia/internal/app"
)
const usage = `tia — Terminal Is A My Way (Just Work)
Pemakaian:
tia Buka TUI interaktif
tia version Tampilkan versi & build info
Subcommand CLI pendamping (convert, ps, up, down, update, doctor)
menyusul di Phase 1–3 — lihat docs/PRD.md §F-028.
`
func main() {
if len(os.Args) > 1 {
switch os.Args[1] {
case "version", "--version":
fmt.Println(versionString())
return
default:
fmt.Fprintf(os.Stderr, "perintah tidak dikenal: %q\n\n%s", os.Args[1], usage)
os.Exit(2)
}
}
if _, err := tea.NewProgram(app.New()).Run(); err != nil {
fmt.Fprintln(os.Stderr, "tia:", err)
os.Exit(1)
}
}
// versionString memakai build info VCS — tanpa ldflags.
func versionString() string {
info, ok := debug.ReadBuildInfo()
if !ok {
return "tia dev"
}
ver := info.Main.Version
if ver == "" || ver == "(devel)" {
ver = "dev"
}
rev, dirty := "", false
for _, s := range info.Settings {
switch s.Key {
case "vcs.revision":
if len(s.Value) >= 7 {
rev = s.Value[:7]
}
case "vcs.modified":
dirty = s.Value == "true"
}
}
out := "tia " + ver
if rev != "" {
out += " (" + rev
if dirty {
out += "-dirty"
}
out += ")"
}
return out
}