Rename and improve the information tool

This commit is contained in:
Přemysl Eric Janouch 2019-04-13 00:06:51 +02:00
parent b2733bf3fd
commit 3080194dc1
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 41 additions and 27 deletions

View File

@ -1,27 +0,0 @@
package main
import (
"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()
if err := printer.Initialize(); err != nil {
log.Fatalln(err)
}
if err := printer.UpdateStatus(); err != nil {
log.Fatalln(err)
}
log.Printf("status\n%s", printer.LastStatus)
}

41
ql-info/main.go Normal file
View File

@ -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")
}
}