Rename type "text" to "line".

pull/10/head v0.1.1
Joshua Potter 2023-11-27 05:03:05 -07:00
parent ef265afc48
commit b283fcdfb8
7 changed files with 17 additions and 17 deletions

View File

@ -24,7 +24,7 @@ We start with an example. Consider the following *spec*, which we'll name
```json
{
"filename": {
"type": "text",
"type": "line",
"prompt": "What file should I create for you? "
}
}
@ -128,7 +128,7 @@ child objects called *fields*. A typical `spec.json` file looks like:
```json
{
"fieldname": {
"type": "text",
"type": "line",
"prompt": "Prompt for field> "
},
...
@ -136,7 +136,7 @@ child objects called *fields*. A typical `spec.json` file looks like:
```
In this example, the first field is called `"fieldname"`. `bootstrap` sees this
field and writes the prompt `"Prompt for field> "` to `stdout`. Since
`"fieldname"` has type `"text"`, `bootstrap` will wait for the user to input
`"fieldname"` has type `"line"`, `bootstrap` will wait for the user to input
a string (submitted with a newline).
If the user were to enter `fieldvalue` in response to the prompt, the `runner`
@ -150,7 +150,7 @@ of alphanumeric characters or underscores and cannot start with a digit.
The value of `type` determines how a field is prompted for. Note the value of
`type` is case insenstive. The currently supported list of types are:
* `text`
* `line`
* The simplest prompt type. Takes in a free-form response submitted after a
newline (`\n`) is encountered.

View File

@ -14,7 +14,7 @@
@brief The types of fields `bootstrap` can handle.
*/
enum FieldType {
FT_TEXT = 1,
FT_LINE = 1,
};
/**
@ -26,11 +26,11 @@ file. For instance, the fields of:
```json
{
"abc": {
"type": "text",
"type": "line",
"prompt": "ABC> "
},
"def": {
"type": "text",
"type": "line",
"prompt": "DEF> "
},
}

View File

@ -1,6 +1,6 @@
{
"app": {
"type": "text",
"type": "line",
"prompt": "App Name> "
}
}

View File

@ -1,6 +1,6 @@
{
"filename": {
"type": "text",
"type": "line",
"prompt": "What file should I create for you? "
}
}

View File

@ -50,7 +50,7 @@ static const char *prompt_field(struct Field *field) {
char *response = calloc(1, 1024);
switch (field->type) {
case FT_TEXT:
case FT_LINE:
// TODO: Probably want this buffer size to be a bit more dynamic.
if (fgets(response, 1024, stdin)) {
size_t len = strlen(response);

View File

@ -67,8 +67,8 @@ static struct Error *read_field(
goto cleanup;
}
if (strcmp_ci(type->valuestring, "text") == 0) {
(*out)->type = FT_TEXT;
if (strcmp_ci(type->valuestring, "line") == 0) {
(*out)->type = FT_LINE;
} else {
error = ERROR_NEW(
ERROR_VALIDATOR_FIELD_TYPE_UNKNOWN,

View File

@ -73,7 +73,7 @@ static void test_validator_field_name_leading_digit() {
struct TestValidatorFixture *fixture = test_validator_setup(
"{"
" \"1abc\": {"
" \"type\": \"text\""
" \"type\": \"line\""
" }"
"}"
);
@ -93,7 +93,7 @@ static void test_validator_field_name_non_alnum() {
struct TestValidatorFixture *fixture = test_validator_setup(
"{"
" \"a~bc\": {"
" \"type\": \"text\""
" \"type\": \"line\""
" }"
"}"
);
@ -150,7 +150,7 @@ static void test_validator_valid_type_ci() {
struct TestValidatorFixture *fixture = test_validator_setup(
"{"
" \"key\": {"
" \"type\": \"tExT\","
" \"type\": \"LiNe\","
" \"prompt\": \"What value for key?\""
" }"
"}"
@ -167,7 +167,7 @@ static void test_validator_field_prompt_invalid() {
struct TestValidatorFixture *fixture = test_validator_setup(
"{"
" \"key\": {"
" \"type\": \"text\","
" \"type\": \"line\","
" \"prompt\": 2"
" }"
"}"
@ -187,7 +187,7 @@ static void test_validator_valid() {
struct TestValidatorFixture *fixture = test_validator_setup(
"{"
" \"key\": {"
" \"type\": \"text\","
" \"type\": \"line\","
" \"prompt\": \"What value for key?\""
" }"
"}"