main.go 896 Bytes
Newer Older
1 2 3 4 5 6
package main

import (
	"dfss"
	"flag"
	"fmt"
7
	"os"
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
	"runtime"
)

var (
	verbose bool
)

func init() {

	flag.BoolVar(&verbose, "v", false, "Print verbose messages")

	flag.Usage = func() {
		fmt.Println("DFSS demonstrator v" + dfss.Version)
		fmt.Println("Debug tool to check remote transmissions")

		fmt.Println("\nUsage:")
24
		fmt.Println("  dfssd [flags] command")
25 26 27 28

		fmt.Println("\nThe commands are:")
		fmt.Println("  help     print this help")
		fmt.Println("  version  print dfss client version")
29
		fmt.Println("  start    start demonstrator server")
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

		fmt.Println("\nFlags:")
		flag.PrintDefaults()

		fmt.Println()
	}
}

func main() {
	flag.Parse()
	command := flag.Arg(0)

	switch command {
	case "version":
		fmt.Println("v"+dfss.Version, runtime.GOOS, runtime.GOARCH)
45 46 47 48 49
	case "start":
		err := listen("localhost:3000")
		if err != nil {
			os.Exit(1)
		}
50 51 52 53
	default:
		flag.Usage()
	}
}