mirror of
https://github.com/therootcompany/golib.git
synced 2026-08-09 22:10:24 +00:00
jsonpaths: auto-enable anonymous mode when no TTY
When input is piped (CI, scripts, AI agents), /dev/tty won't exist. Previously this crashed with 'cannot open /dev/tty'. Now we detect the absence of a TTY and auto-enable --anonymous mode.
This commit is contained in:
parent
aab60c7ac2
commit
fabd193884
@ -89,6 +89,15 @@ func main() {
|
||||
fs.BoolVar(&cfg.noCache, "no-cache", false, "skip local cache for URL inputs")
|
||||
fs.StringVar(&cfg.user, "user", "", "HTTP basic auth (user:password, like curl)")
|
||||
|
||||
// Auto-enable anonymous mode when there's no TTY (piped input, CI, etc.).
|
||||
if !cfg.anonymous {
|
||||
if f, err := os.Open("/dev/tty"); err != nil {
|
||||
cfg.anonymous = true
|
||||
} else {
|
||||
f.Close()
|
||||
}
|
||||
}
|
||||
|
||||
// Handle version/help before flag parse
|
||||
if len(os.Args) > 1 {
|
||||
switch os.Args[1] {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user