From 27c097eb72ae0fe13fe6883c06587fe86b585c64 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Sat, 25 Nov 2023 12:48:21 -0700 Subject: [PATCH] Don't format the prompt. --- README.md | 11 +++++++---- src/evaluator.c | 7 ++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7280e64..4a8ee23 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ We start with an example. Consider the following *spec*, which we'll name { "filename": { "type": "STRING", - "prompt": "What file should I create for you?" + "prompt": "What file should I create for you? " } } ``` @@ -43,12 +43,15 @@ Running `bootstrap` with these two files configured will invoke the following interactive script: ```bash > bootstrap example -What file should I create for you? hello-world.txt -Creating hello-world.txt +I: What file should I create for you? hello-world.txt +O: Creating hello-world.txt > ``` -You should now see a new `hello-world.txt` file in the current directory. +Here the line prefixed with `I:` indicates a prompt that must be answered by +the user. The line prefixed with `O:` indicates the output of the builder +script. You should now see a new `hello-world.txt` file in your current working +directory. ## Usage diff --git a/src/evaluator.c b/src/evaluator.c index 49ec859..45b7c54 100644 --- a/src/evaluator.c +++ b/src/evaluator.c @@ -46,9 +46,10 @@ static const char *prompt_field(struct Field *field) { switch (field->type) { case FT_STRING: - printf("%s> ", field->prompt); - char *input = calloc(1, 256); - if (fgets(input, 256, stdin)) { + printf("%s", field->prompt); + // TODO: Probably want this buffer size to be a bit more dynamic. + char *input = calloc(1, 1024); + if (fgets(input, 1024, stdin)) { size_t len = strlen(input); if (len > 0 && input[len - 1] == '\n') { input[len - 1] = '\0';