aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-03-27 17:58:47 -0500
committerAnthony Wang2022-03-27 17:58:47 -0500
commita5977b9500bbd5486e9fae080ac49d9325b0d1ae (patch)
treee6bca0c76466ad5e9a0c93e54e4d919257ea7c3a
parentf038ce57449fcbcba31b229ed0f0090c07eff34f (diff)
Add golang.org/x/term module for raw input
-rw-r--r--go.mod5
-rw-r--r--go.sum4
-rw-r--r--sd.go15
3 files changed, 22 insertions, 2 deletions
diff --git a/go.mod b/go.mod
index 94d9d02..fda4565 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,8 @@
module sd
go 1.18
+
+require (
+ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
+ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..26b086d
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,4 @@
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
diff --git a/sd.go b/sd.go
index 52a7925..5480499 100644
--- a/sd.go
+++ b/sd.go
@@ -1,9 +1,20 @@
package main
import (
- "fmt"
+ "flag"
+ "os"
+
+ "golang.org/x/term"
)
+var file = flag.String("f", "cards", "cards file")
+
func main() {
- fmt.Println("hello world")
+ flag.Parse()
+
+ oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
+ if err != nil {
+ panic(err)
+ }
+ defer term.Restore(int(os.Stdin.Fd()), oldState)
}