examples/interact.go
changeset 4 a8fbec71a194
child 6 8e425e340ca1
equal deleted inserted replaced
3:6121aa2f21b1 4:a8fbec71a194
       
     1 // Copyright 2011 The Go Authors.  All rights reserved.
       
     2 // Use of this source code is governed by a BSD-style
       
     3 // license that can be found in the LICENSE file.
       
     4 
       
     5 package main
       
     6 
       
     7 import (
       
     8 	"cjyar/xmpp"
       
     9 	"flag"
       
    10 	"log"
       
    11 	"os"
       
    12 	)
       
    13 
       
    14 // Demonstrate the API, and allow the user to interact with an XMPP
       
    15 // server via the terminal.
       
    16 func main() {
       
    17 	var jid xmpp.JID
       
    18 	flag.Var(&jid, "jid", "JID to log in as")
       
    19 	var pw *string = flag.String("pw", "", "password")
       
    20 	flag.Parse()
       
    21 	if jid.Domain == "" || *pw == "" {
       
    22 		flag.Usage()
       
    23 		os.Exit(2)
       
    24 	}
       
    25 
       
    26 	c, err := xmpp.NewClient(&jid, *pw)
       
    27 	if err != nil {
       
    28 		log.Fatalf("NewClient(%v): %v", jid, err)
       
    29 	}
       
    30 	defer c.Close()
       
    31 }