Skip to content

Commit 4d13e03

Browse files
committed
Abort early if neither --host nor --list are set
1 parent cad8d8e commit 4d13e03

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

terraformedinventory.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ func main() {
2929
flag.Parse()
3030
file := flag.Arg(0)
3131

32-
if !*list && *host == "" {
33-
}
34-
3532
if file == "" {
3633
fmt.Printf("Usage: %s [options] path\n", os.Args[0])
3734
os.Exit(1)
3835
}
3936

37+
if !*list && *host == "" {
38+
fmt.Println("Either --host or --list must be specified")
39+
os.Exit(1)
40+
}
41+
4042
path, err := filepath.Abs(file)
4143
if err != nil {
4244
fmt.Printf("Invalid file: %s\n", err)
@@ -62,10 +64,6 @@ func main() {
6264
} else if *host != "" {
6365
host := mustGetHost(state, *host)
6466
os.Stdout.Write(mustMarshal(host.vars))
65-
66-
} else {
67-
fmt.Println("Either --host or --list must be specified")
68-
os.Exit(1)
6967
}
7068
}
7169

0 commit comments

Comments
 (0)