From 90baaa35af72ba59dece080e76cbe9f1ffd6b763 Mon Sep 17 00:00:00 2001 From: Vojtech Vitek Date: Tue, 16 Jan 2018 18:42:06 -0500 Subject: [PATCH 1/2] Support Supfile.yml Fixes #100 --- cmd/sup/main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/sup/main.go b/cmd/sup/main.go index 6de5ad9..ee3ea48 100644 --- a/cmd/sup/main.go +++ b/cmd/sup/main.go @@ -50,7 +50,7 @@ func (f *flagStringSlice) Set(value string) error { } func init() { - flag.StringVar(&supfile, "f", "./Supfile", "Custom path to Supfile") + flag.StringVar(&supfile, "f", "", "Custom path to ./Supfile[.yml]") flag.Var(&envVars, "e", "Set environment variables") flag.Var(&envVars, "env", "Set environment variables") flag.StringVar(&sshConfig, "sshconfig", "", "Read SSH Config file, ie. ~/.ssh/config file") @@ -211,10 +211,16 @@ func main() { return } + if supfile == "" { + supfile = "./Supfile" + } data, err := ioutil.ReadFile(resolvePath(supfile)) if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) + data, err = ioutil.ReadFile(resolvePath("./Supfile.yml")) // Alternative to ./Supfile. + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } } conf, err := sup.NewSupfile(data) if err != nil { From 80cf49bde3de8ee79c45ecc4c173ebbf8ca53d7e Mon Sep 17 00:00:00 2001 From: Vojtech Vitek Date: Tue, 16 Jan 2018 18:45:56 -0500 Subject: [PATCH 2/2] Print both errors on missing ./Supfile and ./Supfile.yml --- cmd/sup/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/sup/main.go b/cmd/sup/main.go index ee3ea48..ebf03d8 100644 --- a/cmd/sup/main.go +++ b/cmd/sup/main.go @@ -216,8 +216,10 @@ func main() { } data, err := ioutil.ReadFile(resolvePath(supfile)) if err != nil { - data, err = ioutil.ReadFile(resolvePath("./Supfile.yml")) // Alternative to ./Supfile. + firstErr := err + data, err = ioutil.ReadFile("./Supfile.yml") // Alternative to ./Supfile. if err != nil { + fmt.Fprintln(os.Stderr, firstErr) fmt.Fprintln(os.Stderr, err) os.Exit(1) }