package jobs

import (
	"github.com/spf13/cobra"
)

// NewJobCmd creates the main 'job' command that contains all job-related subcommands
func NewJobCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "job",
		Short: "Job management commands",
		Long: `Job management commands for running and controlling jobs.

All commands support short-form UUIDs (first 8 characters) if they uniquely identify a job.

Available subcommands:
  run        Run a new job immediately or schedule it for later
  list       List all jobs with status and details
  status     Show comprehensive status of a specific job
  log        Stream logs from a job (historical + live)
  metrics    View resource metrics (CPU, memory, I/O, network, GPU)
  telematics View eBPF security events (exec, connect, accept, etc.)
  stop       Stop a running job (sends SIGTERM/SIGKILL)
  cancel     Cancel a scheduled job (status becomes CANCELED)
  delete     Delete a specific job and all its data
  delete-all Delete all non-running jobs

Examples:
  rnx job run python script.py           # Run a job
  rnx job list                           # List all jobs
  rnx job status f47ac10b                # Check job status
  rnx job log f47ac10b                   # Stream logs
  rnx job metrics f47ac10b               # View resource metrics
  rnx job telematics f47ac10b            # View eBPF security events`,
	}

	// Add all job-related subcommands
	cmd.AddCommand(NewRunCmd())
	cmd.AddCommand(NewListCmd())
	cmd.AddCommand(NewStatusCmd())
	cmd.AddCommand(NewLogCmd())
	cmd.AddCommand(NewMetricsCmd())
	cmd.AddCommand(NewTelematicsCmd())
	cmd.AddCommand(NewStopCmd())
	cmd.AddCommand(NewCancelCmd())
	cmd.AddCommand(NewDeleteCmd())
	cmd.AddCommand(NewDeleteAllCmd())

	return cmd
}
