<commit_before>#include <stdlib.h>
#include <stdio.h>

#include "src/sea.h"

#define USAGE "Usage: %s [-d] input_filename\n"

int main(int argc, char* argv[]) {
    // parse arguments
    char opt;
    extern int optind;
    while((opt = getopt(argc, argv, "d")) != -1) {
        switch(opt) {
            case 'd': {
                extern int yydebug;
                yydebug = 1;
                break;
            }
            case '?': {
                fprintf(stderr, USAGE, argv[0]);
                exit(EXIT_FAILURE);
            }
        }
    }

    if (optind >= argc) {
        fprintf(stderr, "Expected argument after options\n");
        fprintf(stderr, USAGE, argv[0]);
        exit(EXIT_FAILURE);
    }

    // use arguments
    char* filename = argv[optind];
    FILE* input_file;
    int is_stdin = strcmp(filename, "-") == 0;

    input_file = is_stdin ? stdin : fopen(filename, "rb");
    if (!input_file) {
        perror("An error occured whilst reading from the input file");
        return -1;
    }

    // main part of program
    sea* s = create_sea();
    int stat = execute_file(s, input_file);
    free_sea(s);

    // cleanup
    if (!is_stdin) {
        if (ferror(input_file)) {
            fprintf(stderr, "An error occured during reading from the file\n");
        }
        fclose(input_file);
    }

    if (stat != 0) {
        fprintf(stderr, "An occured during parsing\n");
        return stat;
    } else {
        return 0;
    }
}
<commit_msg>Give more useful help info<commit_after>#include <stdlib.h>
#include <stdio.h>

#include "src/sea.h"

void print_usage(char** argv) {
    printf("Usage:   %s [-d] input_filename\n", argv[0]);
    printf("Options: -h     Print this help message\n");
    printf("         -d     Print lexing debug messages\n");

    printf("\n");
    printf("         [input_filename] can be a dash (-) for reading a program\n");
    printf("                          from standard in\n");
}


int main(int argc, char* argv[]) {
    // parse arguments
    char opt;
    extern int optind;
    while((opt = getopt(argc, argv, "dh")) != -1) {
        switch(opt) {
            case 'd': {
                extern int yydebug;
                yydebug = 1;
                break;
            }
            case 'h':
            case '?': {
                print_usage(argv);
                exit(EXIT_FAILURE);
            }
        }
    }

    if (optind >= argc) {
        fprintf(stderr, "Expected argument after options\n");
        print_usage(argv);
        exit(EXIT_FAILURE);
    }

    // use arguments
    char* filename = argv[optind];
    FILE* input_file;
    int is_stdin = strcmp(filename, "-") == 0;

    input_file = is_stdin ? stdin : fopen(filename, "rb");
    if (!input_file) {
        perror("An error occured whilst reading from the input file");
        return -1;
    }

    // main part of program
    sea* s = create_sea();
    int stat = execute_file(s, input_file);
    free_sea(s);

    // cleanup
    if (!is_stdin) {
        if (ferror(input_file)) {
            fprintf(stderr, "An error occured during reading from the file\n");
        }
        fclose(input_file);
    }

    if (stat != 0) {
        fprintf(stderr, "An occured during parsing\n");
        return stat;
    } else {
        return 0;
    }
}

{'fraction_non_alphanumeric': 0.1340175067914277, 'fraction_numerical': 0.004527618472683369, 'mean_word_length': 1.7616666666666667, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4060291', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1045, 'n_words': 279}