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.

53 lines
1.2 KiB
Go

package main
import (
"fmt"
"flag"
"log"
"os"
"strconv"
"FRMS/internal/pkg/tui"
"FRMS/internal/pkg/logging"
)
type TUI interface {
Start()
}
func NewTUI(ip string, port int, ifconfig string, ch chan error) TUI {
return tui.NewTUI(ip, port, ifconfig, ch)
}
func main() {
var port int
var err error
flag.Usage = func() {
w := flag.CommandLine.Output()
fmt.Fprintf(w,"Usage: %s port [eth*, wlan*, etc.]\n", os.Args[0])
}
// iptr := flag.String("i","192.168.100.2","ip address of listener")
iptr := flag.String("i","192.1.168.136","ip address of laptop")
flag.Parse()
if flag.NArg() != 2 {
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)
}
ifconfig := string(args[1])
ip := *iptr
ch := make(chan error)
t := NewTUI(ip,port,ifconfig,ch)
go t.Start()
logging.Debug(logging.DStart, "Started TUI Client")
err = <-ch
if err != nil {
log.Fatal(err)
}
}