/dsa-commiter

A cli tool to auto-commit your LeetCode solutions and track your progress

Primary LanguagePython

DSA Commiter CLI

A lightweight command-line tool to create directories and files for your DSA (Data Structures & Algorithms) solutions and automatically commit and push them to GitHub. Perfect for tracking LeetCode progress.


πŸ“Œ Why I Built This

I’ve been grinding LeetCode following NeetCode’s roadmap β€” and while solving problems regularly helped, I realized I had no proper system to track my progress.

I wanted something simple that could:

  • Create folders and files for each solution
  • Let me write the solution code directly in the terminal
  • Automatically commit and push it to GitHub

So I built DSA Commiter CLI β€” a lightweight command-line tool that does all this in seconds.


Features

  • πŸ“ Create directories and files with default code templates (e.g., .py, .js, .cpp)
  • ✍️ Add multiline content (e.g., LeetCode solutions) with Ctrl+D or two blank lines to finish
  • πŸ”„ Automatically git add, commit, and push to your current branch (main or master)
  • 🎨 Clean, colorful terminal interface using rich
  • πŸ›‘οΈ Robust error handling for file creation and Git operations

Quick Start

Clone the repository:

git clone https://github.com/sem22-dev/dsa-commiter.git
cd dsa-commiter

πŸ’» Installation

🌐 macOS / Linux

Run the installation script:

chmod +x install.sh
./install.sh

πŸ“Ί Windows

Run the batch installer:

install.bat

Make sure you have Python, pip, and Git in your system PATH.


πŸ’» Usage

Navigate to a project directory linked with a remote repository. Then run:

dsa-commiter

Follow the prompts to:

  • πŸ“‚ Enter a directory name (or press Enter for current directory)
  • πŸ“„ Enter a file name (e.g., solution.py)
  • ✍️ Enter file content (e.g., a LeetCode solution), ending with Ctrl+D or two blank lines
  • πŸ”„ The CLI auto-commits and pushes to your current branch

Example:

πŸ“ Enter directory name (or press Enter): problems
πŸ“ Supported file extensions: .py, .js, .cpp, .java, .c, .txt
πŸ“„ Enter file name (e.g., solution.py): solution.py
πŸ“ Enter file content (Ctrl+D or two blank lines to end):
def twoSum(nums, target):
    seen = {}
    for i, num in enumerate(nums):
        complement = target - num
        if complement in seen:
            return [seen[complement], i]
        seen[num] = i
    return []
[Ctrl+D]

πŸ“… Created directory: /path/to/problems
πŸ“… Created file: /path/to/problems/solution.py
πŸ”’ Added file: problems/solution.py
πŸ“… Committed with message: 'problems/solution.py solution'
πŸ› Pushed file: problems/solution.py to branch 'master'

If dsa-commiter is not recognized, use:

venv\Scripts\activate
python -m dsa_commiter.cli_interface

πŸ“ Project Structure

dsa-commiter/
β”œβ”€β”€ dsa_commiter/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ cli_interface.py
β”‚   β”œβ”€β”€ file_operations.py
β”‚   β”œβ”€β”€ git_operations.py
β”œβ”€β”€ install.sh
β”œβ”€β”€ install.bat
β”œβ”€β”€ setup.py
β”œβ”€β”€ README.md

πŸ“œ Requirements

  • Python 3.7+
  • Git
  • rich library (installed via script)

πŸ“„ License

MIT License


Happy Coding! πŸŽ‰