int main(int argc, char *argv[]) {
    145 int batch_mode = (argc == 2);
    146 char input[INPUT_BUFFER_SIZE];
    147 FILE *input_stream;
    148 149 150 User *user_list = NULL;
    151 152 if (batch_mode) {
        153 input_stream = fopen(argv[1], "r");
        154 if (input_stream == NULL) {
            155 perror("Error opening file");
            156 exit(1);
            157
        }
        158
    }
    else {
        159 160 input_stream = stdin;
        161
    }
    162 163 printf("Welcome to FriendMe! (Local version)\nPlease type a command:\n> ");
    164 165 while (fgets(input, INPUT_BUFFER_SIZE, input_stream) != NULL) {
        166 167 168 if (batch_mode) {
            169 printf("%s", input);
            170
        }
        171 172 char *cmd_argv[INPUT_ARG_MAX_NUM];
        173 int cmd_argc = tokenize(input, cmd_argv);
        174 175 if (cmd_argc > 0 && process_args(cmd_argc, cmd_argv, &user_list) == -1) {
            176 break;
            177
        }
        178 179 printf("> ");
        180
    }
    181 182 if (batch_mode) {
        183 fclose(input_stream);
        184
    }
    185 186 return 0;
    187
}