#Indentation go brr

1 messages · Page 1 of 1 (latest)

obtuse oyster
#
                #include <iostream>
                #include <filesystem>
                #include <string>
                #include <set>

                namespace fs = std::filesystem;

                int main(int argc, char* argv[]) {
            std::set<std::string> ext{".dvi", ".aux", ".log", ".out", ".toc", ".synctex.gz", ".fdb_latexmk", ".fls", ".gz", ".xdv"};
            if (argc < 2) {
        std::cout << "Usage: " << argv[0] << " <directory_path>\n";
        return 1;
            }

            if (argc > 2) {
        std::cerr << "Error: Too many arguments\n";
        return 1;
            }
    
            std::string directoryPath;
            if (argc == 1)
        directoryPath = argv[1];
            else
        directoryPath = fs::current_path().string();
            if (!fs::exists(directoryPath)) {
        std::cerr << "Error: " << argv[1] << " does not exist\n";
        return 1;
            }

            try {
        for (const auto& entry : fs::directory_iterator(directoryPath)) {
    if (ext.count(entry.path().extension()) == 1) {
fs::remove(entry.path());
    }
        }
        std::cout << "All auxiliary latex files have been removed from " << directoryPath << "\n";
            } catch (const fs::filesystem_error& e) {
        std::cerr << "Error: " << e.what() << "\n";
        return 1;
            }

            return 0;
                }
potent radish
#

Outdentation