diff options
author | Ben Burwell <ben@benburwell.com> | 2020-06-06 17:02:38 -0400 |
---|---|---|
committer | Ben Burwell <ben@benburwell.com> | 2020-06-06 17:02:38 -0400 |
commit | da8aa52b5ce6d948a346d7dbf1254ca3faaeac80 (patch) | |
tree | 503ed27704aab39c824abcbd8a08d4f60fb39e49 /main.go | |
parent | 34060154caf34fc8d709135be803e08855496614 (diff) |
Add status subcommandstatus
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 29 |
1 files changed, 6 insertions, 23 deletions
@@ -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 -} |