How shubhamoy/dir2txt works
Project type and purpose
• From the file tree and README, this is a C++20 command‑line tool (“dir2txt”) that walks a source directory, applies ignore rules and optional comment stripping, then serializes both the directory structure and file contents into either plain text or JSON.
• It is designed as a standalone CLI utility to feed downstream AI/LLM workflows (RAG, embeddings, code‑aware agents).
File structure
• Top‑level build files: CMakeLists.txt, .gitignore, LICENSE, README.md.
• /: public headers defining interfaces and component classes (IDirectoryWalker, IFileFilter, IWriter, and implementations).
• src/: private implementation .cpp files and main.cpp.
• Key modules:
• Config / cxxopts (command‑line option parsing)
• UniversalIgnoreParser (loads .gitignore/.dockerignore/custom ignores)
• DirectoryWalker (recursive file‑system traversal, using std::filesystem)
• FileFilter (filters by extension, binary detector in Utils)
• CommentStripper (optional AST‑style or regex‑based comment removal)
• FileWriterText / FileWriterJson (strategy pattern for output format)
• Utils (binary detection, path helpers)
README for additional insights
• Describes features (ignore support, comment stripping, JSON or text output) and typical AI‑pipeline integration.