mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-05-27 12:52:27 +02:00
refactor: consolidate service commands into modular structure with complete logic
Replace individual service command initialization with unified InitServiceCmd() that creates a complete service command hierarchy. Port all original logic from initStartCmd, initStopCmd, initRestartCmd, initReloadCmd, initStatusCmd, and initUninstallCmd into ServiceCommand methods with proper dependency injection. Key changes: - Port complete Start logic including config validation, service installation, DNS management, and self-check functionality - Port complete Stop logic with deactivation pin validation and DNS cleanup - Port complete Restart logic with config validation and DNS restoration - Port complete Reload logic with HTTP status handling and restart fallback - Port complete Status logic with proper exit codes - Port complete Uninstall logic with cleanup file removal - Add all necessary flags to service commands (iface, pin, etc.) - Use InitInterfacesCmd() for interfaces subcommand - Simplify cli.go by replacing multiple init calls with single InitServiceCmd() This refactoring eliminates code duplication, improves maintainability, and ensures all service commands have their complete original functionality.
This commit is contained in:
committed by
Cuong Manh Le
parent
aa8af67365
commit
35cc8adecb
+1
-8
@@ -128,14 +128,7 @@ func initCLI() {
|
||||
rootCmd.CompletionOptions.HiddenDefaultCmd = true
|
||||
|
||||
initRunCmd()
|
||||
startCmd := initStartCmd()
|
||||
stopCmd := initStopCmd()
|
||||
restartCmd := initRestartCmd()
|
||||
reloadCmd := initReloadCmd(restartCmd)
|
||||
statusCmd := initStatusCmd()
|
||||
uninstallCmd := initUninstallCmd()
|
||||
interfacesCmd := initInterfacesCmd()
|
||||
initServicesCmd(startCmd, stopCmd, restartCmd, reloadCmd, statusCmd, uninstallCmd, interfacesCmd)
|
||||
InitServiceCmd()
|
||||
initClientsCmd()
|
||||
initUpgradeCmd()
|
||||
InitLogCmd()
|
||||
|
||||
Reference in New Issue
Block a user