use super::battlegroup_flows::battlegroup_kubernetes_step;
use super::flow_models::{
    step, BattlegroupCommand, BattlegroupCommandSpec, StepAction, StepDomain, StepFlags,
};

pub(super) fn extended_command_specs() -> Vec<BattlegroupCommandSpec> {
    vec![
        BattlegroupCommandSpec::new(
            BattlegroupCommand::BackupDatabase,
            "backup",
            "Take a database backup",
            vec![step(
                "bg.database.backup",
                "Take database backup",
                StepDomain::Kubernetes,
                StepAction::Export,
                "/home/dune/.dune/bin/battlegroup backup",
                "Future native database backup workflow",
                StepFlags::new(false, true),
            )],
        ),
        BattlegroupCommandSpec::new(
            BattlegroupCommand::ImportDatabase,
            "import",
            "Import a database backup",
            vec![step(
                "bg.database.import",
                "Import database backup",
                StepDomain::Kubernetes,
                StepAction::Import,
                "/home/dune/.dune/bin/battlegroup import",
                "Future guarded native database import workflow",
                StepFlags::new(false, true),
            )],
        ),
        BattlegroupCommandSpec::new(
            BattlegroupCommand::LogsExport,
            "logs-export",
            "Retrieves logs from all pods in the selected battlegroup",
            vec![battlegroup_kubernetes_step(
                "bg.command.logs-export",
                "Collect battlegroup pod logs",
                StepAction::Export,
                "kubectl get pods -o json; kubectl logs per container",
                "StructuredBattlegroupOps::export_namespace_logs",
            )],
        ),
        BattlegroupCommandSpec::new(
            BattlegroupCommand::OperatorLogsExport,
            "operator-logs-export",
            "Retrieves logs from all operator pods",
            vec![battlegroup_kubernetes_step(
                "bg.command.operator-logs-export",
                "Collect operator pod logs",
                StepAction::Export,
                "kubectl get pods -n funcom-operators -o json; kubectl logs per container",
                "StructuredBattlegroupOps::export_operator_logs",
            )],
        ),
        BattlegroupCommandSpec::new(
            BattlegroupCommand::OpenFileBrowser,
            "open-file-browser",
            "Open the file browser in a web browser",
            vec![step(
                "bg.filebrowser.open",
                "Open File Browser URL",
                StepDomain::Browser,
                StepAction::Open,
                "Start-Process http://ip:18888",
                "Return URL to caller; UI opens it",
                StepFlags::new(false, false),
            )],
        ),
        BattlegroupCommandSpec::new(
            BattlegroupCommand::OpenDirector,
            "open-director",
            "Open the director web app in a web browser",
            vec![
                step(
                    "bg.director.discover-port",
                    "Discover Director NodePort",
                    StepDomain::Kubernetes,
                    StepAction::Detect,
                    "kubectl get svc port 11717 nodePort",
                    "Kubernetes service discovery",
                    StepFlags::new(false, false),
                ),
                step(
                    "bg.director.open",
                    "Open Director URL",
                    StepDomain::Browser,
                    StepAction::Open,
                    "Start-Process http://ip:nodePort",
                    "Return URL to caller; UI opens it",
                    StepFlags::new(false, false),
                ),
            ],
        ),
        BattlegroupCommandSpec::new(
            BattlegroupCommand::ShellVm,
            "shell-vm",
            "Open an SSH shell on the VM",
            vec![step(
                "bg.shell.vm",
                "Open VM shell",
                StepDomain::Ssh,
                StepAction::Shell,
                "ssh -t dune@ip",
                "Interactive terminal adapter",
                StepFlags::new(false, false),
            )],
        ),
        BattlegroupCommandSpec::new(
            BattlegroupCommand::ShellPod,
            "shell-pod",
            "Open a shell inside a pod of the selected battlegroup",
            vec![
                step(
                    "bg.shell-pod.discover",
                    "Discover namespace and pods",
                    StepDomain::Kubernetes,
                    StepAction::Detect,
                    "kubectl get pods -n ns",
                    "Kubernetes pod list",
                    StepFlags::new(false, false),
                ),
                step(
                    "bg.shell-pod.open",
                    "Open pod shell",
                    StepDomain::Kubernetes,
                    StepAction::Shell,
                    "kubectl exec -it pod -- bash/sh",
                    "Interactive Kubernetes exec adapter",
                    StepFlags::new(false, false),
                ),
            ],
        ),
        BattlegroupCommandSpec::new(
            BattlegroupCommand::StartVm,
            "start-vm",
            "Start the VM",
            vec![
                step(
                    "bg.vm.start",
                    "Start VM",
                    StepDomain::HyperV,
                    StepAction::Start,
                    "Start-VM",
                    "Hyper-V provider start_vm",
                    StepFlags::new(true, false),
                ),
                step(
                    "bg.vm.wait-ip",
                    "Wait for VM IPv4",
                    StepDomain::HyperV,
                    StepAction::Wait,
                    "Get-VMNetworkAdapter IPAddresses loop",
                    "Hyper-V provider wait_ipv4",
                    StepFlags::new(true, false),
                ),
            ],
        ),
        BattlegroupCommandSpec::new(
            BattlegroupCommand::StopVm,
            "stop-vm",
            "Stop the VM",
            vec![step(
                "bg.vm.stop",
                "Stop VM",
                StepDomain::HyperV,
                StepAction::Stop,
                "Stop-VM -Force",
                "Hyper-V provider stop_vm",
                StepFlags::new(true, false),
            )],
        ),
        BattlegroupCommandSpec::new(
            BattlegroupCommand::Quit,
            "quit",
            "Exit this script",
            vec![step(
                "bg.quit",
                "Quit menu",
                StepDomain::Interactive,
                StepAction::Complete,
                "break loop",
                "Return control to caller",
                StepFlags::new(false, false),
            )],
        ),
    ]
}
