From c26d2e206839340f2659ee9f5698d7ea6712a91d Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 27 Sep 2023 12:31:25 -0500 Subject: [PATCH] fix: Local-interchain cleanup (#710) (#799) * Fix compiler error * Use go run in Makefile Prevents needing to build the binary first. * Remove unecessary init functions * Remove unecessary global var * Fix misspelling in var name * Revert "Remove unecessary global var" This reverts commit 20cf604118819402c06c21e089e57e43f8895bc3. * Add comment for why InstallDir must be public --------- Co-authored-by: Reece Williams (cherry picked from commit 5c4c2b60b53cb5913485ee49c1511d3d0039de3e) Co-authored-by: David Nix --- local-interchain/Makefile | 2 +- local-interchain/cmd/local-ic/chains.go | 4 ---- local-interchain/cmd/local-ic/main.go | 4 ++++ local-interchain/cmd/local-ic/new_chain.go | 4 ---- local-interchain/cmd/local-ic/root.go | 1 + local-interchain/cmd/local-ic/start_chain.go | 4 ---- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/local-interchain/Makefile b/local-interchain/Makefile index 637308389..4df91e194 100644 --- a/local-interchain/Makefile +++ b/local-interchain/Makefile @@ -12,7 +12,7 @@ build: .PHONY: run run: - ../bin/local-ic $(filter-out $@,$(MAKECMDGOALS)) + go run ./cmd/local-ic $(filter-out $@,$(MAKECMDGOALS)) .PHONY: install install: diff --git a/local-interchain/cmd/local-ic/chains.go b/local-interchain/cmd/local-ic/chains.go index 004932086..6b52894b3 100644 --- a/local-interchain/cmd/local-ic/chains.go +++ b/local-interchain/cmd/local-ic/chains.go @@ -59,7 +59,3 @@ func GetFiles() []string { return fileNames } - -func init() { - rootCmd.AddCommand(chainsCmd) -} diff --git a/local-interchain/cmd/local-ic/main.go b/local-interchain/cmd/local-ic/main.go index bbcb4f8ef..a78af4c51 100644 --- a/local-interchain/cmd/local-ic/main.go +++ b/local-interchain/cmd/local-ic/main.go @@ -6,6 +6,10 @@ import ( ) func main() { + rootCmd.AddCommand(chainsCmd) + rootCmd.AddCommand(newChainCmd) + rootCmd.AddCommand(startCmd) + if err := rootCmd.Execute(); err != nil { fmt.Fprintf(os.Stderr, "error while executing your CLI. Err: %v\n", err) os.Exit(1) diff --git a/local-interchain/cmd/local-ic/new_chain.go b/local-interchain/cmd/local-ic/new_chain.go index 545cbded1..b12e67ebb 100644 --- a/local-interchain/cmd/local-ic/new_chain.go +++ b/local-interchain/cmd/local-ic/new_chain.go @@ -180,7 +180,3 @@ func getOrDefault[T any](output string, defaultVal T) T { return any(text).(T) } - -func init() { - rootCmd.AddCommand(newChainCmd) -} diff --git a/local-interchain/cmd/local-ic/root.go b/local-interchain/cmd/local-ic/root.go index fdfc2a908..45d3dfff8 100644 --- a/local-interchain/cmd/local-ic/root.go +++ b/local-interchain/cmd/local-ic/root.go @@ -10,6 +10,7 @@ import ( ) var ( + // This must be global for the Makefile to build properly (ldflags). MakeFileInstallDirectory string ) diff --git a/local-interchain/cmd/local-ic/start_chain.go b/local-interchain/cmd/local-ic/start_chain.go index b1f7bedba..8bcd95b22 100644 --- a/local-interchain/cmd/local-ic/start_chain.go +++ b/local-interchain/cmd/local-ic/start_chain.go @@ -30,7 +30,3 @@ var startCmd = &cobra.Command{ interchain.StartChain(parentDir, configPath) }, } - -func init() { - rootCmd.AddCommand(startCmd) -}