aboutsummaryrefslogtreecommitdiff
path: root/cmd/ql-info
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2019-04-14 22:30:40 +0200
committerPřemysl Janouch <p@janouch.name>2019-04-14 22:30:40 +0200
commit1331f3b5642f521236fcb1ec21ee43d5b76c0b91 (patch)
tree1213c2f2014cf0eff5a4a881b02cbebf91a604b8 /cmd/ql-info
parent7d9410c6b3a724e3670941f7ec2d00e7966d0b1a (diff)
downloadsklad-1331f3b5642f521236fcb1ec21ee43d5b76c0b91.tar.gz
sklad-1331f3b5642f521236fcb1ec21ee43d5b76c0b91.tar.xz
sklad-1331f3b5642f521236fcb1ec21ee43d5b76c0b91.zip
Move commands under cmd/
Diffstat (limited to 'cmd/ql-info')
-rw-r--r--cmd/ql-info/main.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/cmd/ql-info/main.go b/cmd/ql-info/main.go
new file mode 100644
index 0000000..8d53d63
--- /dev/null
+++ b/cmd/ql-info/main.go
@@ -0,0 +1,41 @@
+package main
+
+import (
+ "fmt"
+ "log"
+
+ "janouch.name/sklad/ql"
+)
+
+func main() {
+ printer, err := ql.Open()
+ if err != nil {
+ log.Fatalln(err)
+ }
+ if printer == nil {
+ log.Fatalln("no suitable printer found")
+ }
+
+ defer printer.Close()
+
+ fmt.Printf("\x1b[1m%s %s\x1b[m\n", printer.Manufacturer, printer.Model)
+ if err := printer.Initialize(); err != nil {
+ log.Fatalln(err)
+ }
+ if err := printer.UpdateStatus(); err != nil {
+ log.Fatalln(err)
+ }
+
+ status := printer.LastStatus
+ fmt.Print(status)
+
+ fmt.Println("\x1b[1mMedia information\x1b[m")
+ if mi := ql.GetMediaInfo(
+ status.MediaWidthMM(), status.MediaLengthMM()); mi != nil {
+ fmt.Println("side margin pins:", mi.SideMarginPins)
+ fmt.Println("print area pins:", mi.PrintAreaPins)
+ fmt.Println("print area length:", mi.PrintAreaLength)
+ } else {
+ fmt.Println("unknown media")
+ }
+}