From ca505f1140429717f610408a60698c54df0d06e3 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 29 Jul 2025 16:51:18 +0700 Subject: [PATCH] refactor: fix createStartCommands to follow single responsibility principle Remove rootCmd.AddCommand call from createStartCommands function. The function should only create and return commands, not add them to the root command hierarchy. This responsibility belongs to the caller (InitServiceCmd). This change improves: - Separation of concerns: function has single responsibility - Testability: no hidden side effects - Flexibility: caller controls command registration - Clean architecture: follows principle of no hidden dependencies --- cmd/cli/commands_service_start.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/cli/commands_service_start.go b/cmd/cli/commands_service_start.go index b1c301b..d5d5150 100644 --- a/cmd/cli/commands_service_start.go +++ b/cmd/cli/commands_service_start.go @@ -373,7 +373,6 @@ NOTE: running "ctrld start" without any arguments will start already installed c } startCmdAlias.Flags().StringVarP(&ifaceStartStop, "iface", "", "auto", `Update DNS setting for iface, "auto" means the default interface gateway`) startCmdAlias.Flags().AddFlagSet(startCmd.Flags()) - rootCmd.AddCommand(startCmdAlias) return startCmd, startCmdAlias }