diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..ab49b7b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: + - repo: local + hooks: + - id: gofumpt + name: gofumpt + entry: bash -c 'make fmt' + language: system + types: ["go"] + files: main.go|cmd\/.*|internal\/.* + pass_filenames: false + - repo: local + hooks: + - id: rebuild-docs + name: rebuild-docs + entry: bash -c 'make docs' + language: system + files: cmd\/.* + pass_filenames: false diff --git a/cmd/root.go b/cmd/root.go index 6b03203..9b22914 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,7 @@ import ( "github.com/spf13/cobra" ) -var Version = "0.0.1" +var Version string type options struct { WorkingDir string `env:"WORKING_DIR" envDefault:"."` diff --git a/cmd/version.go b/cmd/version.go index e0a836b..bc30bc3 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -37,6 +37,7 @@ func versionCmd(Version string) *cobra.Command { return cmd } +// Fetch latest release for comparison to current version func latestRelease() (string, error) { resp, err := http.Get("https://api.github.com/repos/RoseSecurity/terramaid/releases/latest") if err != nil { @@ -57,6 +58,7 @@ func latestRelease() (string, error) { return release.TagName, nil } +// Display out of date warning func updateTerramaid(latestVersion string) { c1 := color.New(color.FgCyan)