Aller au contenu
A flat 2D digital drawing shows a stylized computer terminal interface in a simple, 8-bit style using five colors. It includes three geometric elements: a yes/no dialog box with check and x icons, a plain input field, and a vertical list with one highlighted selection. The design features clean lines and a solid color setting with no background details or human figures, all within a 128 by 128 pixel square.

Entrée Utilisateur

AI generated translation.

GenAIScript fournit diverses fonctions pour obtenir une entrée utilisateur lors de l’exécution d’un script. Ceci est utile pour créer une expérience “humain dans la boucle” dans vos scripts.

Lors de l’exécution de CLI, l’entrée utilisateur se fait via le terminal.

Pose une question à l’utilisateur et attend une réponse oui/non. Elle retourne un boolean.

true/false
const ok = await host.confirm("Do you want to continue?")

Pose une question à l’utilisateur et attend une saisie de texte. Elle retourne une string.

const name = await host.input("What is your name?")

Pose une question à l’utilisateur et attend une sélection dans une liste d’options. Elle retourne une string.

const choice = await host.select("Choose an option:", [
"Option 1",
"Option 2",
"Option 3",
])

Les fonctions d’entrée utilisateur retournent undefined lorsqu’elles sont exécutées dans des environnements CI.