Skip to content

Conversation

caarlos0
Copy link
Member

@caarlos0 caarlos0 commented Apr 10, 2025

  • consistent handling of title, spacing, styles, etc
  • do not echo back the user input
  • more tests
  • tested it with voiceover as well, this seems to be the least horrible working state i could get it to
  • file allowed types fix
  • fix multiselect max selected text
  • text inputs respect echo mode*

*: Realistically, we can only either enable or disable echo, and to do that, the input needs to be a terminal.

example usage:

package main

import (
	"errors"
	"log"

	"github.com/charmbracelet/huh"
)

func validate(s string) error {
	if s == "" {
		return errors.New("Input cannot be empty")
	}
	return nil
}

func main() {
	form := huh.NewForm(
		huh.NewGroup(
			huh.NewInput().
				EchoMode(huh.EchoModePassword).
				Validate(validate).
				Title("Type in your password:"),
			huh.NewInput().
				Validate(validate).
				Title("Type in your name:"),
		),
	).WithAccessible(true)

	err := form.Run()
	if err != nil {
		log.Fatal(err)
	}
}

closes #619

@caarlos0 caarlos0 self-assigned this Apr 10, 2025
@caarlos0 caarlos0 requested a review from a team as a code owner April 10, 2025 15:32
@caarlos0 caarlos0 requested review from raphamorim and removed request for a team April 10, 2025 15:32
@caarlos0 caarlos0 marked this pull request as draft April 10, 2025 15:32
@caarlos0 caarlos0 changed the title feat(accessibility): password prompting feat(accessibility): prompt improvements Apr 14, 2025
@caarlos0 caarlos0 marked this pull request as ready for review April 14, 2025 13:14
@caarlos0 caarlos0 requested a review from Copilot April 14, 2025 13:14
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 14 out of 16 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • examples/go.mod: Language not supported
  • go.mod: Language not supported

@caarlos0 caarlos0 requested review from Copilot and bashbunni April 14, 2025 13:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 14 out of 16 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • examples/go.mod: Language not supported
  • go.mod: Language not supported
Comments suppressed due to low confidence (1)

field_multiselect.go:728

  • In the multi-select accessible mode, when a user selects 0 to confirm selection and the validation passes, the loop fails to exit, resulting in an infinite loop. Add a break statement after successful validation inside the if(choice == 0) block.
if choice == 0 {

@caarlos0 caarlos0 merged commit 151ba05 into main Apr 14, 2025
40 checks passed
@caarlos0 caarlos0 deleted the passwords-accessible branch April 14, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TERM=dumb should not expose passwords on the terminal
1 participant