Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed May 25, 2024
1 parent 4001009 commit 88b9c89
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 8 deletions.
Empty file.
32 changes: 32 additions & 0 deletions examples/filepicker/demo.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Set Shell bash

Set Width 800
Set Height 725

Hide
Type "clear && go build -o file"
Enter
Show

Sleep .5s
Type "./file" Sleep .5s
Enter

Sleep 1s
Type "Frank" Sleep 500ms
Enter

Sleep 1s
Type "_frank" Sleep 500ms
Enter

Sleep 1s
Enter
Sleep 1s
Type@200ms "jjjj"
Sleep 1s
Enter

Sleep 1.5s
Type "hunter2"
Sleep 4s
20 changes: 13 additions & 7 deletions examples/filepicker/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"fmt"

"github.com/charmbracelet/huh"
)

Expand All @@ -11,16 +9,24 @@ func main() {

huh.NewForm(
huh.NewGroup(
huh.NewInput().Title("Name").Description("What's your name?"),
huh.NewInput().
Title("Name").
Description("What's your name?"),

huh.NewInput().
Title("Username").
Description("Select your username."),

huh.NewFilePicker().
Title("Select a file:").
Description("This will be your profile image.").
Title("Profile").
Description("Select your profile picture.").
AllowedTypes([]string{".png", ".jpeg", ".webp", ".gif"}).
Value(&file),

huh.NewInput().Title("Name").Description("What's your name?"),
huh.NewInput().
Title("Password").
EchoMode(huh.EchoModePassword).
Description("Set your Password."),
),
).WithShowHelp(true).Run()
fmt.Println(file)
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added examples/filepicker/profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion field_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ func (t *Text) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case key.Matches(msg, t.keymap.Editor):
ext := strings.TrimPrefix(t.editorExtension, ".")
tmpFile, _ := os.CreateTemp(os.TempDir(), "*."+ext)
cmd := exec.Command(t.editorCmd, append(t.editorArgs, tmpFile.Name())...) //nolint:gosec
//nolint:gosec
cmd := exec.Command(t.editorCmd, append(t.editorArgs, tmpFile.Name())...)
_ = os.WriteFile(tmpFile.Name(), []byte(t.textarea.Value()), os.ModePerm)
cmds = append(cmds, tea.ExecProcess(cmd, func(error) tea.Msg {
content, _ := os.ReadFile(tmpFile.Name())
Expand Down

0 comments on commit 88b9c89

Please sign in to comment.