Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions SPEC.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
PROJECT: mini-todo
AUTHOR: Rashid Buzurtanov 92414781214
VERSION: v1
DATE: 2026-05-22

=== 1. Overview ===
This is a command-line interface (CLI) task management application (mini-todo).
In version V1, the focus is to transition all user-facing outputs and error messages into Turkish, and enforce strict argument checks.

=== 2. Commands and Behavior ===

The application is executed via: `python solution_v1.py <command> [arguments]`

* init
- Description: Initializes the storage directory.
- Behavior: Creates a hidden directory named `.minitodo` and an empty `tasks.dat` file inside it.
- Output (Success): "Bos minitodo sistemi '.minitodo/' altinda basariyla olusturuldu."
- Output (Error): If `.minitodo` already exists, prints:
"Hata: Sistem zaten baslatilmis!"

* add <description>
- Description: Adds a new task to the system.
- Behavior: Appends the task with an auto-incremented ID, status (PENDING), and date to `tasks.dat`.
- Output (Success): "Gorev #<ID> eklendi: <description>"
- Output (Error - Missing Argument): If no description is provided, prints:
"Kullanim Hasi: Lutfen gorev aciklamasi yazin. Ornek: add 'Sut al'"

* list / done / delete
- Description: These commands are placeholders for V1 and are not fully implemented yet.
- Output: "Komut '<command_name>' gelecek haftalarda yuklenecektir."

=== 3. Global Error Handling ===

* System Not Initialized:
- If any command (except init) is run before initialization, prints:
"Hata: Sistem henuz baslatilmamis. Once 'init' calistirin."

* Unknown Command:
- If an invalid command is entered, prints:
"Hata: Bilinmeyen komut -> <command_name>"

=== 4. V1 Constraints ===
- No loops (`for` or `while`) are allowed in the source code.
- No lists (`[]`) or dynamic structures can be used; arguments must be accessed via direct indices of `sys.argv`.
58 changes: 58 additions & 0 deletions solution_v1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import sys
import os

# ==============================================================================
# V1 GÖREV LİSTESİ (V1 TASK LIST)
# 1. Hata mesajlarının tamamı kullanıcı dostu ve Türkçe hale getirilecek.
# 2. 'add' komutunda argüman eksikliği kontrolü sıkılaştırılacak ve Türkçe kılavuz basılacak.
# 3. 'init' komutunda halihazırda dizin varsa dönen hata mesajı netleştirilecek.
# ==============================================================================

def initialize():
if os.path.exists(".minitodo"):
return "Hata: Sistem zaten baslatilmis!"

os.mkdir(".minitodo")
f = open(".minitodo/tasks.dat", "w")
f.close()
return "Bos minitodo sistemi '.minitodo/' altinda basariyla olusturuldu."

def add_task(description):
if not os.path.exists(".minitodo"):
return "Hata: Sistem henuz baslatilmamis. Once 'init' calistirin."

f = open(".minitodo/tasks.dat", "r")
content = f.read()
f.close()

task_id = content.count("\n") + 1

f = open(".minitodo/tasks.dat", "a")
f.write(str(task_id) + "|" + description + "|PENDING|2026-05-22\n")
f.close()

return "Gorev #" + str(task_id) + " eklendi: " + description

def show_not_implemented(command_name):
return "Komut '" + command_name + "' gelecek haftalarda yuklenecektir."

# --- Ana Program ---
if len(sys.argv) < 2:
print("Kullanim: python solution_v1.py <komut> [argumanlar]")
else:
command = sys.argv[1]

if command == "init":
print(initialize())

elif command == "add":
if len(sys.argv) < 3:
print("Kullanim Hasi: Lutfen gorev aciklamasi yazin. Ornek: add 'Sut al'")
else:
print(add_task(sys.argv[2]))

elif command == "list" or command == "done" or command == "delete":
print(show_not_implemented(command))

else:
print("Hata: Bilinmeyen komut -> " + command)
43 changes: 43 additions & 0 deletions test_spec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import subprocess
import os
import shutil

# --- Yardimci Fonksiyon ---
def run_cmd(args):
result = subprocess.run(
["python", "solution_v1.py"] + args,
capture_output=True,
text=True
)
return result.stdout.strip()

# --- Setup ve Temizlik ---
def setup_function():
if os.path.exists(".minitodo"):
shutil.rmtree(".minitodo")

# --- V1 Testleri ---

# 1. 'init' komutunun dizin olusturma testi
def test_init_creates_directory():
output = run_cmd(["init"])
assert os.path.exists(".minitodo")
assert "basariyla olusturuldu" in output

# 2. 'init' komutunun tekrar calistirilma hata testi
def test_init_already_exists():
run_cmd(["init"])
output = run_cmd(["init"])
assert "Sistem zaten baslatilmis" in output

# 3. 'add' komutu ile tek bir gorev ekleme testi
def test_add_single_task():
run_cmd(["init"])
output = run_cmd(["add", "Sut al"])
assert "Gorev #1 eklendi" in output

# 4. 'add' komutunda eksik arguman hata testi
def test_missing_arguments_add():
run_cmd(["init"])
output = run_cmd(["add"])
assert "Kullanim Hasi" in output