aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go29
1 files changed, 6 insertions, 23 deletions
diff --git a/main.go b/main.go
index 8c49ce3..52a47ba 100644
--- a/main.go
+++ b/main.go
@@ -1,16 +1,10 @@
package main
import (
- "errors"
"fmt"
"os"
)
-type Conf struct {
- Source string
- Dest string
-}
-
func main() {
conf, err := loadConf()
if err != nil {
@@ -18,7 +12,7 @@ func main() {
os.Exit(1)
}
if len(os.Args) < 2 {
- fmt.Printf("usage: conf <adopt|apply> [files...]\n")
+ fmt.Printf("usage: conf <adopt|apply|status> [files...]\n")
os.Exit(1)
}
switch os.Args[1] {
@@ -32,24 +26,13 @@ func main() {
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)
}
}
-
-func loadConf() (*Conf, error) {
- source := os.Getenv("CONF_SOURCE")
- info, err := os.Stat(source)
- if err != nil {
- return nil, err
- }
- if !info.IsDir() {
- return nil, errors.New("CONF_SOURCE is not a directory")
- }
- home, err := os.UserHomeDir()
- if err != nil {
- return nil, err
- }
- return &Conf{Source: source, Dest: home}, nil
-}