-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.go
36 lines (30 loc) · 1.18 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"fmt"
"go-flags"
"os"
)
type programOptions struct {
Region string `short:"r" long:"region" required:"yes" description:"The CloudControl region to use."`
Datacenter string `short:"d" long:"datacenter" required:"yes" description:"The CloudControl data centre containing the resource(s) to export."`
NetworkDomains []string `short:"n" long:"networkdomain" description:"The network domain(s) to export."`
Servers []string `short:"s" long:"server" description:"The server(s) to export."`
NoRecurse bool `long:"no-recurse" description:"Don't recursively export child resources."`
Version bool `long:"version" description:"Display the current program version."`
Verbose bool `short:"v" long:"verbose" description:"Display detailed information about the exporter's activities."`
}
func parseOptions() programOptions {
options := programOptions{}
parser := flags.NewParser(&options, flags.Default)
_, err := parser.ParseArgs(os.Args)
if err != nil {
switch err.(type) {
case *flags.Error:
// Ignore, since the parser will print it out anyway.
default:
fmt.Print(err.Error())
}
os.Exit(1)
}
return options
}