From d2781c024757c25abd654f202f80a2c70baa56c0 Mon Sep 17 00:00:00 2001 From: DaanSelen Date: Thu, 2 Apr 2026 11:48:23 +0200 Subject: [PATCH] chore: add silent checkbox --- src/main.go | 5 +++-- src/modules/draw/draw.go | 15 ++++++++++++--- src/modules/runner/runner.go | 11 ++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main.go b/src/main.go index 914c41c..60b227b 100644 --- a/src/main.go +++ b/src/main.go @@ -35,9 +35,10 @@ func main() { targEntry := widget.NewEntry() var book string + var silent bool - inputContainer := draw.MakeInput(targEntry, &book) - footerContainer := draw.MakeFooter(targEntry, &book, app) + inputContainer := draw.MakeInput(targEntry, &book, &silent) + footerContainer := draw.MakeFooter(targEntry, &book, &silent, app) center := container.NewBorder( nil, // top diff --git a/src/modules/draw/draw.go b/src/modules/draw/draw.go index cfa60da..dcbdb0b 100644 --- a/src/modules/draw/draw.go +++ b/src/modules/draw/draw.go @@ -13,15 +13,24 @@ import ( tasks "patchworks/src/modules/tasks" ) -func MakeInput(targEntry *widget.Entry, book *string) *fyne.Container { +func MakeInput(targEntry *widget.Entry, book *string, silent *bool) *fyne.Container { availBooks, err := tasks.ListAvailableBooks() if err != nil { log.Println("failed to read available books on disk") } + silentCheck := widget.NewCheck("Silent (Return Only JSON Data)", func(checked bool) { + if checked { + *silent = true + } else { + *silent = false + } + }) + targetBox := container.NewVBox( widget.NewLabel("MeshCentral Target Group"), targEntry, + silentCheck, widget.NewLabel(""), canvas.NewLine(color.Gray{Y: 128}), ) @@ -55,7 +64,7 @@ func MakeInput(targEntry *widget.Entry, book *string) *fyne.Container { return inputBox } -func MakeFooter(targEntry *widget.Entry, book *string, app fyne.App) *fyne.Container { +func MakeFooter(targEntry *widget.Entry, book *string, silent *bool, app fyne.App) *fyne.Container { var result string textEntry := widget.NewMultiLineEntry() @@ -89,7 +98,7 @@ func MakeFooter(targEntry *widget.Entry, book *string, app fyne.App) *fyne.Conta log.Println("kicking off goroutine") actionBtn.Disable() go func() { - ok, result = runner.RunMeshbook(path, *book, targEntry.Text) + ok, result = runner.RunMeshbook(path, *book, *silent, targEntry.Text) if !ok { log.Println("assuming failed state") fyne.CurrentApp().Driver().DoFromGoroutine(func() { diff --git a/src/modules/runner/runner.go b/src/modules/runner/runner.go index 4bd9ae5..c42df24 100644 --- a/src/modules/runner/runner.go +++ b/src/modules/runner/runner.go @@ -45,17 +45,26 @@ func FindMeshbookBinary() (bool, string) { } } -func RunMeshbook(binPath, bookPath, targGroup string) (bool, string) { +func RunMeshbook(binPath, bookPath string, silent bool, targGroup string) (bool, string) { + // Meshbook argument compilation var args []string if len(bookPath) == 0 { args = []string{"--help"} } else { args = []string{"--nograce", "--indent", "-mb", bookPath, "--group", targGroup} } + + if silent { + args = append(args, "--silent") + } + + // Display what we are about to be running log.Printf("running with parameters: %v", args) + // Actually spawn the process cmd := exec.Command(binPath, args...) + // Capture stdout & stderr outputData, err := cmd.CombinedOutput() cleanData := ansi.ReplaceAllString(string(outputData), "")