Synsema docsENES

Humano en el loop

Los gates de aprobación y las preguntas son primitivas del lenguaje — devuelven valores sobre los que ramificás.

human.syn
-- Doc example: human interaction. The primitives are interactive; this shows the
-- documented NON-TTY behavior (CI/tests/pipes), which is deterministic.
intent: "doc example: human interaction (non-TTY)"

print("ask picked → " + (ask "Pick an environment" with ["staging", "prod"]))    -- no TTY → first

test "ask with options takes the FIRST option when there is no TTY (CI/tests/pipes)"
    let choice be ask "Pick an environment" with ["staging", "prod"]
    assert_eq(choice, "staging")

Primitivas

let ok be approve "¿Deploy a producción?"               -- gate sí/no (devuelve un bool)
confirm "¿Mandar email a 500 clientes?"                 -- confirmación
let env be ask "¿Qué entorno?" with ["staging", "prod"]
show data as "Preview"                                  -- mostrar a un humano

Usalas como expresiones:

when approve "Pago grande: $" + text(amount)
    process_payment()
otherwise
    cancel()

Backends

Sin TTY (pipes / CI / tests)

Sin un TTY interactivo, el ask "q" de texto libre devuelve "" y ask "q" with [opts] toma la primera opción (como muestra el doctest de arriba). No confíes en el ask de texto libre para entrada ahí. Para stdin que funciona con pipes, usá read_line(prompt?); para entrada estilo config trivial de testear, usá env("NAME", "default").