Add ability to start tui with no input file
static void usage() {
// clang-format off
fprintf(stderr,
- "Usage: ui [options] infile\n\n"
+ "Usage: ui [options] [file]\n\n"
"Options:\n"
" -h or --help Print this message and exit.\n"
);
@@ -247,13 +247,9 @@ int main(int argc, char** argv) {
fprintf(stderr, "Expected only 1 file argument.\n");
return 1;
}
- if (input_file == NULL) {
- fprintf(stderr, "No input file.\n");
- usage();
- return 1;
- }
Field field;
+ if (input_file) {
field_init(&field);
Field_load_error fle = field_load_file(input_file, &field);
if (fle != Field_load_error_ok) {
@@ -281,6 +277,10 @@ int main(int argc, char** argv) {
fprintf(stderr, "File load error: %s.\n", errstr);
return 1;
}
+ } else {
+ input_file = "unnamed";
+ field_init_fill(&field, 25, 57, '.');
+ }
Markmap_reusable markmap_r;
markmap_reusable_init(&markmap_r);
markmap_reusable_ensure_size(&markmap_r, field.height, field.width);
