Metadata-Version: 2.4
Name: cfmate
Version: 0.2.1
Summary: A fast Codeforces CLI tool for fetching problems and testing competitive programming solutions
Author: Saksham Tale
License: MIT License
        
        Copyright (c) 2026 Saksham Tale
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Repository, https://github.com/Saksham-cmd-tech/cf_tool.git
Keywords: codeforces,competitive-programming,cli
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typer[all]>=0.12
Requires-Dist: rich>=13.7
Requires-Dist: cloudscraper>=1.2.71
Requires-Dist: beautifulsoup4>=4.12
Dynamic: license-file

# cfmate — Fast Codeforces CLI for Competitive Programming

**cfmate** is a fast, developer-friendly CLI tool for Codeforces that lets you fetch problems, view them in a clean format, and test your solutions directly from the terminal.

It is designed to eliminate context switching and streamline the competitive programming workflow.

---

## 🚀 Why cfmate?

Competitive programming usually involves:

* switching between browser and editor
* manually copying test cases
* repeatedly fetching problem statements

**cfmate solves this by bringing everything into your terminal.**

With cfmate, you can:

* fetch problems instantly
* run solutions with sample tests
* cache problems locally for speed
* stay fully inside your development environment

---

## ✨ Features

### 🔍 Problem Fetching

Fetch any Codeforces problem directly:

```bash
cf get 1829A
```

* Displays formatted problem statement
* Includes input/output format
* Shows sample test cases
* Uses clean terminal rendering

---

### 🧪 Solution Testing

Run your solution against sample tests:

```bash
cf run solution.py --problem 1829A
```

* Executes all sample test cases
* Shows pass/fail results
* Displays clear output differences
* Returns proper exit codes (useful for scripting)

---

### ⚡ Smart Caching System

* Problems are stored locally in `.cf_cache/`
* Eliminates repeated network requests
* Provides instant access after first fetch

---

### 🧠 Smart Problem Detection

You don’t always need to specify the problem:

```bash
cf run 1829A.py
```

* Automatically extracts problem ID from filename
* Reduces command verbosity

---

### 🌐 Multi-language Support

Supports multiple programming languages:

| Language   | Execution           |
| ---------- | ------------------- |
| Python     | `python3 file.py`   |
| C++        | `g++ -O2` then run  |
| C          | `gcc -O2` then run  |
| Java       | `javac` + `java`    |
| JavaScript | `node file.js`      |
| TypeScript | `ts-node file.ts`   |
| Go         | `go run file.go`    |
| Rust       | `rustc -O` then run |
| Ruby       | `ruby file.rb`      |

---

### 🎯 Clean Developer Experience

* Minimal and readable terminal output
* No unnecessary clutter
* Fast execution and feedback loop

---

## 📦 Installation

Install directly from PyPI:

```bash
pip install cfmate
```

---

## ⚡ Quick Start

### 1. Fetch a problem

```bash
cf get 1829A
```

---

### 2. Solve it in your editor

Create a file:

```bash
1829A.py
```

---

### 3. Run tests

```bash
cf run 1829A.py
```

---

## 📘 Detailed Usage

### Fetching Problems

```bash
cf get <problem_id>
```

Examples:

```bash
cf get 1829A
cf get 2227D --no-cache
```

Options:

* `--no-cache` → force re-fetch from Codeforces

---

### Running Solutions

```bash
cf run <file> [options]
```

Examples:

```bash
cf run solution.py --problem 1829A
cf run 1829A.py
cf run 2227D.cpp
```

Options:

* `--problem` / `-p` → specify problem ID manually
* `--time-limit` → override execution time limit

Example:

```bash
cf run solution.py -p 1829A --time-limit 2000
```

---

### Creating Files and Folders

```bash
cf create <target> [lang]
```

Modes:

```bash
cf create 2227        # create contest2227/ folder
cf create A py        # create 2227A.py inside current contest folder
cf create 2227A py    # create folder + file
```

Behavior:

* Creates `contest<id>/` folder if not present
* Generates file using language template
* Automatically infers problem ID
* Optionally fetches and caches the problem

---

### Cache Management

```bash
cf cache <command>
```

Commands:

```bash
cf cache list
cf cache clear 1829A
cf cache clear
```

---

## 🗂 Cache System (Detailed)

### Location

Cache is stored in:

```bash
.cf_cache/
```

Each problem is stored as a JSON file:

```bash
.cf_cache/
  ├── 1829A.json
  ├── 2227D.json
```

When using `cf create`, cache is stored inside the contest folder:

```bash
contest2227/
  ├── 2227A.py
  └── .cf_cache/
      └── 2227A.json
```

---

### Cache Behavior

| Scenario          | Behavior                        |
| ----------------- | ------------------------------- |
| Not cached        | Fetch from Codeforces and store |
| Cached            | Load instantly                  |
| Corrupted cache   | Re-fetch automatically          |
| `--no-cache` used | Skip cache and overwrite        |

---

### Benefits

* Faster repeated runs
* Reduced network usage
* Offline access after first fetch

---

## 🧪 Exit Codes

| Code | Meaning                  |
| ---- | ------------------------ |
| `0`  | All tests passed         |
| `1`  | One or more tests failed |

Useful for:

* scripting
* CI pipelines
* automation

---

## ⚠️ Disclaimer

This tool is not affiliated with Codeforces.

It fetches publicly available problem statements for personal use only.
All problem content belongs to Codeforces: https://codeforces.com

Users are responsible for complying with Codeforces Terms:
https://codeforces.com/terms

This tool does not store or redistribute problems beyond local caching.

---

## 🔗 Links

* PyPI: https://pypi.org/project/cfmate/
* GitHub: https://github.com/Saksham-cmd-tech/cf_tool.git

---

## 📄 License

MIT
