Beispiel #1
0
func Action(c *cli.Context) {
	if len(c.Args()) != 1 {
		logrus.Fatalf("usage: gotty-client [GoTTY URL]")
	}

	// setting up logrus
	logrus.SetOutput(os.Stderr)
	if c.Bool("debug") {
		logrus.SetLevel(logrus.DebugLevel)
	} else {
		logrus.SetLevel(logrus.InfoLevel)
	}

	// create Client
	url := c.Args()[0]
	client, err := gottyclient.NewClient(url)
	if err != nil {
		logrus.Fatalf("Cannot create client: %v", err)
	}

	// loop
	if err = client.Loop(); err != nil {
		logrus.Fatalf("Communication error: %v", err)
	}
}
Beispiel #2
0
func main() {
	flag.Usage = usage
	flag.Parse()

	args := flag.Args()
	if len(args) < 1 {
		logrus.Fatalf("GoTTY URL is missing.")
	}

	// create Client
	client, err := gottyclient.NewClient(flag.Arg(0))
	if err != nil {
		logrus.Fatalf("Cannot create client: %v", err)
	}

	// loop
	err = client.Loop()
	if err != nil {
		logrus.Fatalf("Communication error: %v", err)
	}
}