Fix array CLI arguments

This commit is contained in:
Bruce Hill 2024-09-04 15:30:38 -04:00
parent e9796e1433
commit 973b1c55c2

View File

@ -3073,7 +3073,7 @@ CORD compile_cli_arg_call(env_t *env, CORD fn_name, type_t *fn_type)
if (Match(t, ArrayType)->item_type->tag != TextType)
compiler_err(NULL, NULL, NULL, "Main function has unsupported argument type: %T (only arrays of Text are supported)", t);
code = CORD_all(code, "else if (pop_flag(argv, &i, \"", flag, "\", &flag)) {\n",
"$", arg->name, " = Text$split(flag, \",\");\n",
"$", arg->name, " = Text$split(flag, Pattern(\",\"));\n",
arg->name, "$is_set = yes;\n"
"}\n");
break;
@ -3125,7 +3125,7 @@ CORD compile_cli_arg_call(env_t *env, CORD fn_name, type_t *fn_type)
"for (; i < argc; i++) {\n"
"if (argv[i]) {\n"
"Text_t arg = Text$from_str(argv[i]);\n"
"Array$insert(&$", arg->name, ", &arg, 0, $ArrayInfo(&$Text));\n"
"Array$insert(&$", arg->name, ", &arg, I(0), sizeof(Text_t));\n"
"argv[i] = NULL;\n"
"}\n"
"}\n",