You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
953 B
Go

package main
import (
"fmt"
"flag"
"log"
"os"
"strconv"
"FRMS/internal/pkg/tui"
)
type TUI interface {
Start()
}
func NewTUI(ip string, port int, ch chan error) TUI {
return tui.NewTUI(ip, port, ch)
}
func main() {
var port int
var err error
flag.Usage = func() {
w := flag.CommandLine.Output()
fmt.Fprintf(w,"Usage: %s port \n", os.Args[0])
}
iptr := flag.String("i","192.1.168.136","ip address of listener")
flag.Parse()
if flag.NArg() != 1 {
flag.Usage()
os.Exit(1)
}
args := flag.Args()
if port, err = strconv.Atoi(args[0]); port < 1024 || port > 65536 {
flag.Usage()
log.Fatal("Port must be between [1023,65535]")
} else if err != nil {
log.Fatal(err)
}
ip := *iptr
ch := make(chan error)
t := NewTUI(ip,port,ch)
go t.Start()
err = <-ch
if err != nil {
log.Fatal(err)
}
}