Files
mautrix-telegram/pkg/gotd/cmd/mtprint/main.go
T
2025-06-27 20:03:37 -07:00

32 lines
618 B
Go

// Binary mtprint pretty-prints MTProto message from binary file.
package main
import (
"flag"
"io"
"os"
"go.mau.fi/mautrix-telegram/pkg/gotd/proto/codec"
)
func main() {
inputName := flag.String("f", "", "input file (blank for stdin)")
format := flag.String("format", "go", "print format")
flag.Parse()
var reader io.Reader = os.Stdin
if *inputName != "" {
f, err := os.Open(*inputName)
if err != nil {
panic(err)
}
defer func() { _ = f.Close() }()
reader = f
}
p := NewPrinter(reader, formats(*format), codec.Intermediate{})
if err := p.Print(os.Stdout); err != nil {
panic(err)
}
}