Mining/cmd/mining/cmd/root.go

51 lines
1.2 KiB
Go
Raw Normal View History

package cmd
import (
feat: Add WebSocket events, simulation mode, and redesigned Miners page WebSocket Real-Time Events: - Add EventHub for broadcasting miner events to connected clients - New event types: miner.starting/started/stopping/stopped/stats/error - WebSocket endpoint at /ws/events with auto-reconnect support - Angular WebSocketService with RxJS event streams and fallback to polling Simulation Mode (miner-ctrl simulate): - SimulatedMiner generates realistic hashrate data for UI development - Supports presets: cpu-low, cpu-medium, cpu-high, gpu-ethash, gpu-kawpow - Features: variance, sine-wave fluctuation, 30s ramp-up, 98% share rate - XMRig-compatible stats format for full UI compatibility - NewManagerForSimulation() skips autostart of real miners Miners Page Redesign: - Featured cards for installed/recommended miners with gradient styling - "Installed" (green) and "Recommended" (gold) ribbon badges - Placeholder cards for 8 planned miners with "Coming Soon" badges - Algorithm badges, GitHub links, and license info for each miner - Planned miners: T-Rex, lolMiner, Rigel, BzMiner, SRBMiner, TeamRedMiner, GMiner, NBMiner Chart Improvements: - Hybrid data approach: live in-memory data while active, database historical when inactive - Smoother transitions between data sources Documentation: - Updated DEVELOPMENT.md with simulation mode usage - Updated ARCHITECTURE.md with WebSocket, simulation, and supported miners table 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 07:11:41 +00:00
"os"
"github.com/Snider/Mining/pkg/mining"
"github.com/spf13/cobra"
)
var (
manager *mining.Manager
)
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "mining",
Short: "Mining CLI - Manage miners with RESTful control",
Long: `Mining is a CLI tool for managing cryptocurrency miners.
It provides commands to start, stop, list, and manage miners with RESTful control capabilities.`,
Version: mining.GetVersion(),
}
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() error {
return rootCmd.Execute()
}
func init() {
cobra.OnInitialize(initManager)
}
// initManager initializes the miner manager
func initManager() {
feat: Add WebSocket events, simulation mode, and redesigned Miners page WebSocket Real-Time Events: - Add EventHub for broadcasting miner events to connected clients - New event types: miner.starting/started/stopping/stopped/stats/error - WebSocket endpoint at /ws/events with auto-reconnect support - Angular WebSocketService with RxJS event streams and fallback to polling Simulation Mode (miner-ctrl simulate): - SimulatedMiner generates realistic hashrate data for UI development - Supports presets: cpu-low, cpu-medium, cpu-high, gpu-ethash, gpu-kawpow - Features: variance, sine-wave fluctuation, 30s ramp-up, 98% share rate - XMRig-compatible stats format for full UI compatibility - NewManagerForSimulation() skips autostart of real miners Miners Page Redesign: - Featured cards for installed/recommended miners with gradient styling - "Installed" (green) and "Recommended" (gold) ribbon badges - Placeholder cards for 8 planned miners with "Coming Soon" badges - Algorithm badges, GitHub links, and license info for each miner - Planned miners: T-Rex, lolMiner, Rigel, BzMiner, SRBMiner, TeamRedMiner, GMiner, NBMiner Chart Improvements: - Hybrid data approach: live in-memory data while active, database historical when inactive - Smoother transitions between data sources Documentation: - Updated DEVELOPMENT.md with simulation mode usage - Updated ARCHITECTURE.md with WebSocket, simulation, and supported miners table 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 07:11:41 +00:00
// Skip for commands that create their own manager (like simulate)
if len(os.Args) > 1 && os.Args[1] == "simulate" {
return
}
if manager == nil {
manager = mining.NewManager()
}
}
// getManager returns the singleton manager instance
func getManager() *mining.Manager {
if manager == nil {
manager = mining.NewManager()
}
return manager
}