From f9b68609ebdffc928f7f6c7c666a15d810d0302e Mon Sep 17 00:00:00 2001 From: "na.luthfi" Date: Mon, 18 Jan 2021 11:02:18 +0700 Subject: [PATCH] feature: add installation command for gocognit --- .gitignore | 3 +- CHANGELOG.md | 9 ++- config/default.go | 2 + config/version.go | 2 +- console/install.go | 61 ++++++++++++------- ...outils_installer.go => golib_installer.go} | 4 +- 6 files changed, 54 insertions(+), 27 deletions(-) rename installer/{goutils_installer.go => golib_installer.go} (82%) diff --git a/.gitignore b/.gitignore index 07cf4c3..d5132e7 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ *.out .idea/ -include/ \ No newline at end of file +include/ +/.vscode \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ae719ca..b47d3d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ #Fer + +## [v1.9.0] - 2021-01-14 +### New Features +- add installation command for gocognit + + ## [v1.8.1] - 2020-10-12 ### Other Improvements @@ -129,7 +135,8 @@ - db migrationfile generator ([#3](https://github.com/kumparan/fer/issues/3)) -[Unreleased]: https://github.com/kumparan/fer/compare/v1.8.1...HEAD +[Unreleased]: https://github.com/kumparan/fer/compare/v1.9.0...HEAD +[v1.9.0]: https://github.com/kumparan/fer/compare/v1.8.1...v1.9.0 [v1.8.1]: https://github.com/kumparan/fer/compare/v1.8.0...v1.8.1 [v1.8.0]: https://github.com/kumparan/fer/compare/v1.7.2...v1.8.0 [v1.7.2]: https://github.com/kumparan/fer/compare/v1.7.1...v1.7.2 diff --git a/config/default.go b/config/default.go index 8998f67..0aa8ab9 100644 --- a/config/default.go +++ b/config/default.go @@ -16,6 +16,8 @@ const ( MockgenInstallerURL = "github.com/golang/mock/mockgen" // RichgoInstallerURL :nodoc: RichgoInstallerURL = "github.com/kyoh86/richgo" + // GocognitInstallerURL :nodoc: + GocognitInstallerURL = "github.com/uudashr/gocognit/cmd/gocognit" // GolintInstallerURL :nodoc: GolintInstallerURL = "github.com/golangci/golangci-lint/cmd/golangci-lint" // ProtobufVersion :nodoc: diff --git a/config/version.go b/config/version.go index d48a33c..8710c8c 100644 --- a/config/version.go +++ b/config/version.go @@ -1,4 +1,4 @@ package config // Version define version of fer -const Version = "v1.8.1" +const Version = "v1.9.0" diff --git a/console/install.go b/console/install.go index 2fccda7..f5ae31d 100644 --- a/console/install.go +++ b/console/install.go @@ -16,11 +16,12 @@ var installCmd = &cobra.Command{ func init() { installCmd.AddCommand(installAllCmd) - installCmd.AddCommand(goUtilsCmd) + installCmd.AddCommand(goLibCmd) installCmd.AddCommand(protocGenCmd) installCmd.AddCommand(mockgenCmd) installCmd.AddCommand(richgoCmd) installCmd.AddCommand(golintCmd) + installCmd.AddCommand(gocognitCmd) installCmd.AddCommand(chglogCmd) installCmd.AddCommand(protobufCmd) installCmd.AddCommand(moddCmd) @@ -36,31 +37,33 @@ var installAllCmd = &cobra.Command{ func installAll(_ *cobra.Command, _ []string) { installer.CheckExistenceOfGolang() installer.CheckGolangVersion() - installer.InstallGoUtils("protoc-gen-go", config.ProtobufInstallerURL) - installer.InstallGoUtils("mockgen", config.MockgenInstallerURL) - installer.InstallGoUtils("richgo", config.RichgoInstallerURL) - installer.InstallGoUtils("golint", config.GolintInstallerURL) - installer.InstallGoUtils("git-chglog", config.ChangeLogInstallerURL) + installer.InstallGoLib("protoc-gen-go", config.ProtobufInstallerURL) + installer.InstallGoLib("mockgen", config.MockgenInstallerURL) + installer.InstallGoLib("richgo", config.RichgoInstallerURL) + installer.InstallGoLib("golint", config.GolintInstallerURL) + installer.InstallGoLib("gocognit", config.GocognitInstallerURL) + installer.InstallGoLib("git-chglog", config.ChangeLogInstallerURL) installer.ProtobufInstaller() installer.InstallModd() os.Exit(0) } -var goUtilsCmd = &cobra.Command{ - Use: "goutils", - Short: "This subcommand to install all go utils", - Long: "To install all goutils, your golang version must %s or latest", - Run: installGoUtilsCmd, +var goLibCmd = &cobra.Command{ + Use: "golib", + Short: "This subcommand to install all go lib", + Long: "To install all go lib, your golang version must %s or latest", + Run: installGoLibCmd, } -func installGoUtilsCmd(_ *cobra.Command, _ []string) { +func installGoLibCmd(_ *cobra.Command, _ []string) { installer.CheckExistenceOfGolang() installer.CheckGolangVersion() - installer.InstallGoUtils("protoc-gen-go", config.ProtobufInstallerURL) - installer.InstallGoUtils("mockgen", config.MockgenInstallerURL) - installer.InstallGoUtils("richgo", config.RichgoInstallerURL) - installer.InstallGoUtils("golint", config.GolintInstallerURL) - installer.InstallGoUtils("git-chglog", config.ChangeLogInstallerURL) + installer.InstallGoLib("protoc-gen-go", config.ProtobufInstallerURL) + installer.InstallGoLib("mockgen", config.MockgenInstallerURL) + installer.InstallGoLib("richgo", config.RichgoInstallerURL) + installer.InstallGoLib("golint", config.GolintInstallerURL) + installer.InstallGoLib("gocognit", config.GocognitInstallerURL) + installer.InstallGoLib("git-chglog", config.ChangeLogInstallerURL) os.Exit(0) } @@ -74,7 +77,7 @@ var protocGenCmd = &cobra.Command{ func installProtocGenCmd(_ *cobra.Command, _ []string) { installer.CheckExistenceOfGolang() installer.CheckGolangVersion() - installer.InstallGoUtils("protoc-gen-go", config.ProtobufInstallerURL) + installer.InstallGoLib("protoc-gen-go", config.ProtobufInstallerURL) os.Exit(0) } @@ -88,7 +91,7 @@ var mockgenCmd = &cobra.Command{ func installMockgenCmd(_ *cobra.Command, _ []string) { installer.CheckExistenceOfGolang() installer.CheckGolangVersion() - installer.InstallGoUtils("mockgen", config.MockgenInstallerURL) + installer.InstallGoLib("mockgen", config.MockgenInstallerURL) os.Exit(0) } @@ -102,7 +105,7 @@ var richgoCmd = &cobra.Command{ func installRichgoCmd(_ *cobra.Command, _ []string) { installer.CheckExistenceOfGolang() installer.CheckGolangVersion() - installer.InstallGoUtils("richgo", config.MockgenInstallerURL) + installer.InstallGoLib("richgo", config.RichgoInstallerURL) os.Exit(0) } @@ -116,7 +119,21 @@ var golintCmd = &cobra.Command{ func installGolintCmd(_ *cobra.Command, _ []string) { installer.CheckExistenceOfGolang() installer.CheckGolangVersion() - installer.InstallGoUtils("golint", config.MockgenInstallerURL) + installer.InstallGoLib("golint", config.GolintInstallerURL) + os.Exit(0) +} + +var gocognitCmd = &cobra.Command{ + Use: "gocognit", + Short: "This subcommand to install Gocognit", + Long: "Gocognit calculates cognitive complexities of functions in Go source code. A measurement of how hard does the code is intuitively to understand.", + Run: installGocognitCmd, +} + +func installGocognitCmd(_ *cobra.Command, _ []string) { + installer.CheckExistenceOfGolang() + installer.CheckGolangVersion() + installer.InstallGoLib("gocognit", config.GocognitInstallerURL) os.Exit(0) } @@ -130,7 +147,7 @@ var chglogCmd = &cobra.Command{ func installChglogCmd(_ *cobra.Command, _ []string) { installer.CheckExistenceOfGolang() installer.CheckGolangVersion() - installer.InstallGoUtils("git-chglog", config.MockgenInstallerURL) + installer.InstallGoLib("git-chglog", config.ChangeLogInstallerURL) os.Exit(0) } diff --git a/installer/goutils_installer.go b/installer/golib_installer.go similarity index 82% rename from installer/goutils_installer.go rename to installer/golib_installer.go index 5dcde4a..c1baf46 100644 --- a/installer/goutils_installer.go +++ b/installer/golib_installer.go @@ -5,8 +5,8 @@ import ( "os/exec" ) -// InstallGoUtils :nodoc: -func InstallGoUtils(installername, URL string) { +// InstallGoLib :nodoc: +func InstallGoLib(installername, URL string) { fmt.Println("Installing ", installername) cmd := exec.Command("go", "get", "-u", URL) err := cmd.Run()