Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Local-interchain cleanup #710

Merged
merged 9 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion local-interchain/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions local-interchain/cmd/local-ic/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,3 @@ func GetFiles() []string {

return fileNames
}

func init() {
rootCmd.AddCommand(chainsCmd)
}
4 changes: 4 additions & 0 deletions local-interchain/cmd/local-ic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions local-interchain/cmd/local-ic/new_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,3 @@ func getOrDefault[T any](output string, defaultVal T) T {

return any(text).(T)
}

func init() {
rootCmd.AddCommand(newChainCmd)
}
Comment on lines -184 to -186
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I avoid init() functions at all costs. Even though this is common in Viper and co-located with the subcommand file, I think it's an anti-pattern. It hides order of operations and hides functionality in the main() function. IOW, I want to look at main() and know exactly what's happening.

1 change: 1 addition & 0 deletions local-interchain/cmd/local-ic/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

var (
// This must be global for the Makefile to build properly (ldflags).
MakeFileInstallDirectory string
)

Expand Down
4 changes: 0 additions & 4 deletions local-interchain/cmd/local-ic/start_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,3 @@ var startCmd = &cobra.Command{
interchain.StartChain(parentDir, configPath)
},
}

func init() {
rootCmd.AddCommand(startCmd)
}