aboutsummaryrefslogtreecommitdiff
path: root/main.go
blob: 52a47ba9e47c21c95554ff1e48feeb2d5afbafa0 (plain)
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
37
38
package main

import (
	"fmt"
	"os"
)

func main() {
	conf, err := loadConf()
	if err != nil {
		fmt.Printf("could not load configuration: %v\n", err)
		os.Exit(1)
	}
	if len(os.Args) < 2 {
		fmt.Printf("usage: conf <adopt|apply|status> [files...]\n")
		os.Exit(1)
	}
	switch os.Args[1] {
	case "apply":
		if err := apply(conf, os.Args[2:]); err != nil {
			fmt.Printf("%v\n", err)
			os.Exit(1)
		}
	case "adopt":
		if err := adopt(conf, os.Args[2:]); err != nil {
			fmt.Printf("%v\n", err)
			os.Exit(1)
		}
	case "status":
		if err := status(conf, os.Args[2:]); err != nil {
			fmt.Printf("%v\n", err)
			os.Exit(1)
		}
	default:
		fmt.Printf("unrecognized command: %s\n", os.Args[1])
		os.Exit(1)
	}
}