-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dec9707
commit 380549f
Showing
7 changed files
with
86 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
|
||
"github.com/gobuffalo/fizz" | ||
"github.com/gobuffalo/fizz/translators" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func main() { | ||
|
||
root := cobra.Command{ | ||
Use: "fizz-validate [path]...", | ||
Short: "Validate fizz files", | ||
Long: "Validate fizz files", | ||
DisableFlagsInUseLine: true, | ||
SilenceUsage: true, | ||
SilenceErrors: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
trans := translators.NewPostgres() | ||
bubbler := fizz.NewBubblerWithDisabledExec(trans) | ||
for _, path := range args { | ||
file, err := os.Open(path) | ||
if err != nil { | ||
return errors.Wrapf(err, "error opening file at path %q", path) | ||
} | ||
b, err := ioutil.ReadAll(file) | ||
if err != nil { | ||
return errors.Wrapf(err, "error reading file at path %q", path) | ||
} | ||
_, err = bubbler.Bubble(string(b)) | ||
if err != nil { | ||
return errors.Wrapf(err, "error translating file at path %q to sql", path) | ||
} | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
if err := root.Execute(); err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu -o pipefail | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
readonly DIR | ||
|
||
# Ensure fizz-validate is available | ||
if ! command -v fizz-validate &> /dev/null; then | ||
echo "error: fizz-validate not installed, install with 'make bin/fizz-validate'" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
# shellcheck disable=SC2068 | ||
fizz-validate $@ |