Add web and CLI UI options for eliminate command with mutual exclusivity and required flag checks

Introduce `--web` and `--cli` flags to select alternative interfaces for the elimination flow. Add validation to enforce mutual exclusivity and ensure one option is specified. Include placeholder logic for web UI implementation.
This commit is contained in:
Evan Hosinski
2025-10-10 22:59:46 -04:00
parent 192ce28d89
commit ec307bc91f
+26 -7
View File
@@ -12,8 +12,9 @@ import (
var ( var (
excludeRMMs []string excludeRMMs []string
inputFile string
outputFile string outputFile string
webUI bool
cliUI bool
) )
// rootCmd represents the base command when called without any subcommands // rootCmd represents the base command when called without any subcommands
@@ -81,9 +82,17 @@ func init() {
huntCmd.Flags().StringVarP(&outputFile, "output", "o", "suspicious-hunter.json", huntCmd.Flags().StringVarP(&outputFile, "output", "o", "suspicious-hunter.json",
"Output file to write hunt results (optional) Default: suspicious-hunter.json") "Output file to write hunt results (optional) Default: suspicious-hunter.json")
// Eliminate command flags (optional input; if omitted, TUI will show a file picker) // Eliminate command flags
eliminateCmd.Flags().StringVarP(&inputFile, "input", "i", "", eliminateCmd.Flags().BoolVarP(&webUI, "web", "w", false,
"JSON input file containing hunt results (optional)") "Use web UI instead of TUI (optional)")
eliminateCmd.Flags().BoolVarP(&cliUI, "cli", "c", false,
"Use CLI UI instead of TUI (optional)")
// Mark web and cli flags as mutually exclusive
eliminateCmd.MarkFlagsMutuallyExclusive("web", "cli")
// Mark one of web or cli as required
eliminateCmd.MarkFlagsOneRequired("web", "cli")
} }
func runHunt() { func runHunt() {
@@ -98,9 +107,19 @@ func runHunt() {
} }
func runEliminate() { func runEliminate() {
// Launch the Charmbracelet-based TUI for elimination flow if webUI {
if err := tui.RunEliminateUI(); err != nil { // Launch the web UI for elimination flow
fmt.Printf("[-] TUI error: %v\n", err) // TODO: Launch web UI
fmt.Println("Web UI not implemented yet")
return
} else if cliUI {
// Launch the TUI for elimination flow
if err := tui.RunEliminateUI(); err != nil {
fmt.Printf("[-] TUI error: %v\n", err)
os.Exit(1)
}
} else {
fmt.Println("No UI specified")
os.Exit(1) os.Exit(1)
} }
} }