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
68 changes: 68 additions & 0 deletions REadME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
mini-bookmark V2

A CLI tool to save and manage web URLs, developed as part of a university assignment at Samsun Üniversitesi.

Student Information

Name: Hüdanur Şener

Student ID: 251478066

Overview

mini-bookmark is a lightweight command-line interface tool that allows users to store, list, search, and delete web bookmarks. All data is persisted in a plain text file (links.dat) located within a hidden .minibookmark/ directory.

V1 vs V2: What's New?

The project has evolved from V1 to V2 with the following key improvements:

Command Completion: In V1, list and delete were placeholders. In V2, they are fully functional.

URL Validation: V2 introduces a safety check ensuring all added URLs start with 'http' or 'https'.

Formatted Output: The list command now presents data in a clean, professional table format.

Enhanced Error Handling: Improved feedback for missing arguments, invalid IDs, and uninitialized states.

V2 Task List

List Command: Implemented full listing of bookmarks with a formatted header and aligned columns.

Delete Command: Added functionality to remove a specific bookmark entry using its ID number.

Validation Logic: Integrated a prefix check for URLs to prevent malformed data entry.

Installation \& Usage

1\. Initialize the Project

python minibookmark.py init

2\. Add a Bookmark

python minibookmark.py add "Google" "https://google.com"

3\. List All Bookmarks

python minibookmark.py list

4\. Search Bookmarks

python minibookmark.py search "keyword"

5\. Delete a Bookmark

python minibookmark.py delete <id>

Data Format

Data is stored in .minibookmark/links.dat using the following structure:

id|title|url|date

License

Educational purpose only.



49 changes: 49 additions & 0 deletions problems/mini-bookmark/SPEC-v1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
PROJECT: mini-bookmark
AUTHOR: Hüdanur Şener (251478066)
VERSION: v0
DATE: 2026-03-16

========================================
OVERVIEW
========================================
mini-bookmark is a CLI tool to save and manage web URLs.
It stores bookmarks in a plain text file.
All data is kept in a directory named .minibookmark/

========================================
COMMANDS
========================================

--- init ---
Usage: python minibookmark.py init
Creates .minibookmark/ directory and an empty links.dat file.
If it exists, prints "Already initialized."

--- add ---
Usage: python minibookmark.py add "Google" "https://google.com"
Saves a new bookmark with an auto-increment ID.
Format: id|title|url|date
Prints: "Added bookmark #<id>: <title>"

--- list ---
Usage: python minibookmark.py list
(To be implemented)
Will show all saved bookmarks.

--- delete ---
Usage: python minibookmark.py delete <id>
(To be implemented)
Will remove a bookmark by ID.

========================================
DATA FORMAT
========================================
File: .minibookmark/links.dat
Format: id|title|url|2026-03-16

========================================
ERROR HANDLING
========================================
- Running without init: "Not initialized. Run: python minibookmark.py init"
- Unknown command: "Unknown command: <command>"
- Missing arguments: "Usage: python minibookmark.py <command> [args]"
54 changes: 54 additions & 0 deletions problems/mini-bookmark/SPEC-v2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
PROJECT: mini-bookmark
AUTHOR: Hüdanur Şener (251478066)
VERSION: v1
DATE: 2026-03-29

========================================
OVERVIEW
========================================
mini-bookmark is a CLI tool to save and manage web URLs.
It stores bookmarks in a plain text file. [cite: 2]
All data is kept in a directory named .minibookmark/

========================================
COMMANDS
========================================

--- init ---
Usage: python minibookmark.py init
Creates .minibookmark/ directory and an empty links.dat file.
If it exists, prints "Already initialized." [cite: 3]

--- add ---
Usage: python minibookmark.py add "Title" "URL"
Saves a new bookmark with an auto-increment ID. [cite: 4]
Format: id|title|url|date
Prints: "Added bookmark #<id>: <title>"

--- list ---
Usage: python minibookmark.py list
(To be implemented)
Will show all saved bookmarks.

--- delete ---
Usage: python minibookmark.py delete <id>
(To be implemented)
Will remove a bookmark by ID. [cite: 5]

--- search ---
Usage: python minibookmark.py search <keyword>
(V1 Update) Searches for bookmarks by title keyword.
[Note: This command was added to meet Assignment 4.2 requirements.]

========================================
DATA FORMAT
========================================
File: .minibookmark/links.dat
Format: id|title|url|2026-03-16 [cite: 6]

========================================
ERROR HANDLING
========================================
- Running without init: "Not initialized. Run: python minibookmark.py init"
- Unknown command: "Unknown command: <command>"
- Missing arguments: "Usage: python minibookmark.py <command> [args]"
57 changes: 57 additions & 0 deletions problems/mini-bookmark/SPEC-v3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
PROJECT: mini-bookmark
AUTHOR: Hüdanur Şener (251478066)
VERSION: v3
DATE: 2026-04-20

========================================
OVERVIEW
========================================
mini-bookmark is a CLI tool to save and manage web URLs[cite: 13].
It stores bookmarks in a plain text file.
All data is kept in a directory named .minibookmark/[cite: 14].

========================================
COMMANDS
========================================

--- init ---
Usage: python minibookmark.py init
Creates .minibookmark/ directory and an empty links.dat file[cite: 15].
If it exists, prints "Already initialized."

--- add ---
Usage: python minibookmark.py add "Title" "URL"
(V2 Update) Saves a new bookmark with an auto-increment ID.
URL must start with "http" or "https"[cite: 16].
Format: id|title|url|date
Prints: "Added bookmark #<id>: <title>"

--- list ---
Usage: python minibookmark.py list
(V2 Update: Implemented) Shows all saved bookmarks in a formatted table[cite: 17].
Displays ID, Title, URL, and Date columns.

--- delete ---
Usage: python minibookmark.py delete <id>
(V2 Update: Implemented) Removes a bookmark by its specific ID from links.dat[cite: 18].
Prints: "Bookmark #<id> deleted." if successful.

--- search ---
Usage: python minibookmark.py search <keyword>
Searches for bookmarks by title keyword (Case-insensitive)[cite: 19].

========================================
DATA FORMAT
========================================
File: .minibookmark/links.dat
Format: id|title|url|YYYY-MM-DD
Example: 1|Google|http://google.com|2026-04-20

========================================
ERROR HANDLING
========================================
- Running without init: "Not initialized. Run: python minibookmark.py init"
- Unknown command: "Unknown command: <command>"
- Missing arguments: "Usage: python minibookmark.py <command> [args]"
- Invalid URL (V2): "Error: URL must start with 'http' or 'https'."
- ID Not Found (V2): "Bookmark #<id> not found."
86 changes: 86 additions & 0 deletions problems/mini-bookmark/TEST-v1 (2).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""
mini-bookmark SPEC test cases
Student:Hüdanur Şener (251478066)
Project: mini-bookmark
"""
import subprocess
import os
import shutil

# --- Helper Function ---
def run_cmd(args):
"""Runs the script and returns the output."""
result = subprocess.run(
["python", "minibookmark.py"] + args,
capture_output=True,
text=True
)
return result.stdout.strip()

def setup_function():
"""Clean start for each test."""
if os.path.exists(".minibookmark"):
shutil.rmtree(".minibookmark")

# --- 1. init COMMAND TESTS ---
def test_init_creates_directory():
# Normal durum: İlk kez init yapilir
run_cmd(["init"])
assert os.path.exists(".minibookmark") == True

def test_init_already_initialized():
# Hata durumu: Zaten init yapilmisken tekrar yapilir
run_cmd(["init"])
output = run_cmd(["init"])
assert "Already initialized" in output

# --- 2. add COMMAND TESTS ---
def test_add_single_bookmark():
# Normal durum: Bir link basariyla eklenir
run_cmd(["init"])
output = run_cmd(["add", "Google", "https://google.com"])
assert "Added bookmark #1" in output

def test_add_multiple_bookmarks():
# Normal durum: İkinci link eklenir ve ID artar
run_cmd(["init"])
run_cmd(["add", "A", "a.com"])
output = run_cmd(["add", "B", "b.com"])
assert "#2" in output

def test_add_missing_arguments():
# Hata durumu: Eksik arguman (sadece isim)
run_cmd(["init"])
output = run_cmd(["add", "OnlyName"])
assert "Usage" in output

# --- 3. ERROR HANDLING & FLOW TESTS ---
def test_command_before_init():
# Hata durumu: Klasor yokken add komutu calismaz
output = run_cmd(["add", "Test", "test.com"])
assert "Not initialized" in output

def test_unknown_command_error():
# Hata durumu: SPEC'te olmayan bir komut
run_cmd(["init"])
output = run_cmd(["jump"])
assert "Unknown command" in output

# --- 4. FUTURE IMPLEMENTATION TESTS (SPEC Status) ---
def test_list_not_implemented_yet():
# SPEC Uyumu: list komutu henuz hazir degil mesaji vermeli
run_cmd(["init"])
output = run_cmd(["list"])
assert "future weeks" in output

def test_delete_not_implemented_yet():
# SPEC Uyumu: delete komutu henuz hazir degil mesaji vermeli
run_cmd(["init"])
output = run_cmd(["delete", "1"])
assert "future weeks" in output

# --- 5. USAGE TESTS ---
def test_no_arguments_usage():
# Hata durumu: Hicbir arguman girilmezse kullanim kilavuzu basilir
output = run_cmd([])
assert "Usage" in output
Loading