From 3e41b6e3ef56aed22e8ac69ebefa32390baae845 Mon Sep 17 00:00:00 2001 From: Henry Dollman Date: Tue, 2 Apr 2024 14:51:46 -0400 Subject: [PATCH] skip form if required flags are set --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 8790673..03d92bd 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,6 @@ type Model struct { filepicker filepicker.Model selectedFilePath string selectedFileName string - done []string } var Program *tea.Program @@ -292,7 +291,6 @@ func main() { filepicker: fp, selectedFilePath: selectedFilePath, selectedFileName: selectedFileName, - done: []string{}, form: huh.NewForm( huh.NewGroup( huh.NewInput(). @@ -327,6 +325,12 @@ func main() { ), } + // if required flags are set, skip form by setting state to completed + skipForm := flag.CommandLine.Changed("crf") && flag.CommandLine.Changed("strip-audio") && flag.CommandLine.Changed("preview") + if skipForm { + m.form.State = huh.StateCompleted + } + Program = tea.NewProgram(m) if _, err := Program.Run(); err != nil { fmt.Printf("Alas, there's been an error: %v", err)