Skip to content

Commit

Permalink
skip form if required flags are set
Browse files Browse the repository at this point in the history
  • Loading branch information
henrygd committed Apr 2, 2024
1 parent dd7126e commit 3e41b6e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type Model struct {
filepicker filepicker.Model
selectedFilePath string
selectedFileName string
done []string
}

var Program *tea.Program
Expand Down Expand Up @@ -292,7 +291,6 @@ func main() {
filepicker: fp,
selectedFilePath: selectedFilePath,
selectedFileName: selectedFileName,
done: []string{},
form: huh.NewForm(
huh.NewGroup(
huh.NewInput().
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3e41b6e

Please sign in to comment.