Skip to content

Commit

Permalink
Merge pull request #25 from kumparan/feature/BAN-8479-add-installatio…
Browse files Browse the repository at this point in the history
…n-command-for-gocognit

feature: add installation command for gocognit
  • Loading branch information
naluthfi authored Jan 21, 2021
2 parents d242f2e + f9b6860 commit 418d57a
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
*.out

.idea/
include/
include/
/.vscode
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#Fer

<a name="v1.9.0"></a>
## [v1.9.0] - 2021-01-14
### New Features
- add installation command for gocognit


<a name="v1.8.1"></a>
## [v1.8.1] - 2020-10-12
### Other Improvements
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion config/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package config

// Version define version of fer
const Version = "v1.8.1"
const Version = "v1.9.0"
61 changes: 39 additions & 22 deletions console/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 418d57a

Please sign in to comment.