<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <xcb/xcb.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_ewmh.h>
#include <xcb/xtest.h>
#include "helpers.h"
#include "xdo.h"

int main(int argc, char *argv[])
{
    if (argc < 2)
        err("No arguments given.\n");

    void (*action) (xcb_window_t win) = NULL;

    if (strcmp(argv[1], "close") == 0)
        action = window_close;
    else if (strcmp(argv[1], "kill") == 0)
        action = window_kill;
    else if (strcmp(argv[1], "hide") == 0)
        action = window_hide;
    else if (strcmp(argv[1], "show") == 0)
        action = window_show;
    else if (strcmp(argv[1], "activate") == 0)
        action = window_activate;
    else if (strcmp(argv[1], "key") == 0)
        action = key_press_release;
    else if (strcmp(argv[1], "button") == 0)
        action = button_press_release;
    else if (strcmp(argv[1], "-h") == 0)
        return usage();
    else if (strcmp(argv[1], "-v") == 0)
        return version();
    else
        err("Unknown action: '%s'.\n", argv[1]);

    init();
    argc--;
    argv++;
    char opt;
    while ((opt = getopt(argc, argv, "rcCdDk:")) != -1) {
        switch (opt) {
            case 'r':
                cfg.wid = VALUE_DIFFERENT;
                break;
            case 'c':
                cfg.class = VALUE_SAME;
                break;
            case 'C':
                cfg.class = VALUE_DIFFERENT;
                break;
            case 'd':
                cfg.desktop = VALUE_SAME;
                break;
            case 'D':
                cfg.desktop = VALUE_DIFFERENT;
                break;
            case 'k':
                cfg.evt_code = atoi(optarg);
                break;
        }
    }

    if (action == NULL)
        return EXIT_FAILURE;

    int num = argc - optind;
    char **args = argv + optind;

    setup();

    if (num > 0) {
        char *end;
        for (int i = 0; i < num; i++) {
            errno = 0;
            long int win = strtol(args[i], &end, 0);
            if (errno != 0 || *end != '\0')
                warn("Invalid window ID: '%s'.\n", args[i]);
            else
                (*action)(win);
        }
    } else {
        if (cfg.wid == VALUE_IGNORE && cfg.class == VALUE_IGNORE && cfg.desktop == VALUE_IGNORE) {
            xcb_window_t win;
            get_active_window(&win);
            (*action)(win);
        } else {<commit_msg>Remove obsolete unknown action test<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <xcb/xcb.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_ewmh.h>
#include <xcb/xtest.h>
#include "helpers.h"
#include "xdo.h"

int main(int argc, char *argv[])
{
    if (argc < 2)
        err("No arguments given.\n");

    void (*action) (xcb_window_t win);

    if (strcmp(argv[1], "close") == 0)
        action = window_close;
    else if (strcmp(argv[1], "kill") == 0)
        action = window_kill;
    else if (strcmp(argv[1], "hide") == 0)
        action = window_hide;
    else if (strcmp(argv[1], "show") == 0)
        action = window_show;
    else if (strcmp(argv[1], "activate") == 0)
        action = window_activate;
    else if (strcmp(argv[1], "key") == 0)
        action = key_press_release;
    else if (strcmp(argv[1], "button") == 0)
        action = button_press_release;
    else if (strcmp(argv[1], "-h") == 0)
        return usage();
    else if (strcmp(argv[1], "-v") == 0)
        return version();
    else
        err("Unknown action: '%s'.\n", argv[1]);

    init();
    argc--;
    argv++;
    char opt;
    while ((opt = getopt(argc, argv, "rcCdDk:")) != -1) {
        switch (opt) {
            case 'r':
                cfg.wid = VALUE_DIFFERENT;
                break;
            case 'c':
                cfg.class = VALUE_SAME;
                break;
            case 'C':
                cfg.class = VALUE_DIFFERENT;
                break;
            case 'd':
                cfg.desktop = VALUE_SAME;
                break;
            case 'D':
                cfg.desktop = VALUE_DIFFERENT;
                break;
            case 'k':
                cfg.evt_code = atoi(optarg);
                break;
        }
    }

    int num = argc - optind;
    char **args = argv + optind;

    setup();

    if (num > 0) {
        char *end;
        for (int i = 0; i < num; i++) {
            errno = 0;
            long int win = strtol(args[i], &end, 0);
            if (errno != 0 || *end != '\0')
                warn("Invalid window ID: '%s'.\n", args[i]);
            else
                (*action)(win);
        }
    } else {
        if (cfg.wid == VALUE_IGNORE && cfg.class == VALUE_IGNORE && cfg.desktop == VALUE_IGNORE) {
            xcb_window_t win;
            get_active_window(&win);
            (*action)(win);
        } else {
{'fraction_non_alphanumeric': 0.15868563414145462, 'fraction_numerical': 0.010819475055099179, 'mean_word_length': 1.6723768736616702, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 27, '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': '3443449', 'n_tokens_mistral': 1754, 'n_tokens_neox': 1686, 'n_words': 420}