1package main
2
3import (
4	"fmt"
5	"io/ioutil"
6	"log"
7	"os"
8
9	"github.com/mitchellh/cli"
10)
11
12func main() {
13	os.Exit(realMain())
14}
15
16func realMain() int {
17	log.SetOutput(ioutil.Discard)
18
19	// Get the command line args. We shortcut "--version" and "-v" to just
20	// show the version.
21	args := os.Args[1:]
22	for _, arg := range args {
23		if arg == "--" {
24			break
25		}
26		if arg == "-v" || arg == "--version" {
27			newArgs := make([]string, len(args)+1)
28			newArgs[0] = "version"
29			copy(newArgs[1:], args)
30			args = newArgs
31			break
32		}
33	}
34
35	cli := &cli.CLI{
36		Args:     args,
37		Commands: Commands,
38		HelpFunc: cli.BasicHelpFunc("sockaddr"),
39	}
40	exitCode, err := cli.Run()
41	if err != nil {
42		fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
43		return 1
44	}
45
46	return exitCode
47}
48