adding version to code
This commit is contained in:
31
main.go
31
main.go
@@ -8,14 +8,31 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
display := os.Getenv("DISPLAY")
|
||||
proxySocket := "/tmp/.X11-unix/X5"
|
||||
const version = "0.1"
|
||||
|
||||
overrideDisplay := flag.String("display", "", "Override DISPLAY")
|
||||
overrideSocket := flag.String("proxy-socket", proxySocket, "Proxy socket path")
|
||||
var (
|
||||
overrideDisplay = flag.String("display", "", "Override DISPLAY")
|
||||
overrideSocket = flag.String("proxy-socket", "/tmp/.X11-unix/X5", "Proxy socket path")
|
||||
showVersion = flag.Bool("version", false, "Show version and exit")
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(os.Stderr, "Usage of %s:\n\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if *showVersion {
|
||||
fmt.Printf("X11Proxy version %s\n", version)
|
||||
return
|
||||
}
|
||||
fmt.Printf("version %s\n", version)
|
||||
|
||||
display := os.Getenv("DISPLAY")
|
||||
if *overrideDisplay != "" {
|
||||
display = *overrideDisplay
|
||||
}
|
||||
@@ -41,7 +58,6 @@ func hexDump(buf []byte) string {
|
||||
for i := 0; i < len(buf); i += 16 {
|
||||
line := fmt.Sprintf("%08x ", i)
|
||||
|
||||
// Hex section
|
||||
for j := 0; j < 16; j++ {
|
||||
if i+j < len(buf) {
|
||||
line += fmt.Sprintf("%02x ", buf[i+j])
|
||||
@@ -49,13 +65,12 @@ func hexDump(buf []byte) string {
|
||||
line += " "
|
||||
}
|
||||
if j == 7 {
|
||||
line += " " // extra space in middle
|
||||
line += " "
|
||||
}
|
||||
}
|
||||
|
||||
line += " |"
|
||||
|
||||
// ASCII section
|
||||
for j := 0; j < 16 && i+j < len(buf); j++ {
|
||||
b := buf[i+j]
|
||||
if b >= 32 && b <= 126 {
|
||||
|
||||
Reference in New Issue
Block a user