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:
Cuong Manh Le
2025-07-28 19:23:38 +07:00
committed by Cuong Manh Le
parent aa8af67365
commit 35cc8adecb
3 changed files with 571 additions and 79 deletions
-1
View File
@@ -82,7 +82,6 @@ func InitInterfacesCmd() *cobra.Command {
},
}
interfacesCmd.AddCommand(listInterfacesCmd)
rootCmd.AddCommand(interfacesCmd)
return interfacesCmd
}