summaryrefslogtreecommitdiffstats
path: root/internal/utils
diff options
context:
space:
mode:
Diffstat (limited to 'internal/utils')
-rw-r--r--internal/utils/tty_unix.go9
-rw-r--r--internal/utils/tty_windows.go13
2 files changed, 22 insertions, 0 deletions
diff --git a/internal/utils/tty_unix.go b/internal/utils/tty_unix.go
new file mode 100644
index 0000000..c344c0f
--- /dev/null
+++ b/internal/utils/tty_unix.go
@@ -0,0 +1,9 @@
+//go:build !windows
+
+package utils
+
+import "os"
+
+func OpenTTY() (*os.File, error) {
+ return os.OpenFile("/dev/tty", os.O_RDWR, 0)
+}
diff --git a/internal/utils/tty_windows.go b/internal/utils/tty_windows.go
new file mode 100644
index 0000000..f40dbda
--- /dev/null
+++ b/internal/utils/tty_windows.go
@@ -0,0 +1,13 @@
+//go:build windows
+
+package utils
+
+import "os"
+
+func OpenTTY() (*os.File, error) {
+ conin, err := os.OpenFile("CONIN$", os.O_RDWR, 0)
+ if err != nil {
+ return nil, err
+ }
+ return conin, nil
+}