initial commit

This commit is contained in:
2026-04-20 21:38:22 +02:00
commit a5c79fb7b5
12 changed files with 821 additions and 0 deletions

41
cli.go Normal file
View File

@@ -0,0 +1,41 @@
// Command-line arguments parsing and formatted console output.
package cli
import (
"os"
"sync"
)
// Terminal capabilites.
type TerminalInfo struct {
IsTTY bool
SupportsColor bool
Width int
}
// Returns cached TerminalInfo for os.Stdin.
var GetStdinInfo = sync.OnceValue(func() TerminalInfo {
return GetTerminalInfo(os.Stdin)
})
// Returns cached TerminalInfo for os.Stdout.
var GetStdoutInfo = sync.OnceValue(func() TerminalInfo {
return GetTerminalInfo(os.Stdout)
})
// Returns cached TerminalInfo for os.Stderr.
var GetStderrInfo = sync.OnceValue(func() TerminalInfo {
return GetTerminalInfo(os.Stderr)
})
type ExitReason uint8
const (
UserError ExitReason = 1
BadUsage = 2
InternalError = 3
)
func ShortCircuit() {
os.Exit(0)
}