A command-line based notepad app written in C that allows users to create, read, update, and delete textfile organized in categories. The system includes automatic versioning and comprehensive operation logging.
- Create new text textfile in different categories
- Read existing textfile
- Update textfile content with automatic version backup
- Delete textfile
- Organized file structure with categories
- Version history for edited textfile
- Complete operation logging with timestamps
- Error handling and input validation
- Color-coded console output
- Clean all textfile with history preservation
NoteCLI/
├── bin/ # Compiled binary
├── src/ # Source code files
├── include/ # Header files
├── data/ # textfile storage
│ ├── notes/ # Note textfile │ ├── logs/ # Operation logs and history
│ │ └── history.txt # Complete operation history
│ └── versions/ # Automatically saved old versions
└── obj/ # Object files
To build the project, run:
makeThis will create the NotesCLI executable in the bin directory.
To clean the build files:
make cleanTo clean all textfile while preserving history:
make clean-docsThis will:
- Ask for confirmation before proceeding
- Remove all textfile in notes, recipes, and versions directories
- Preserve the operation history in data/logs/history.txt
- Log the cleanup operation with timestamp
The NotesCLI supports the following commands:
# Create a new textfile
./bin/NotesCLI create <filename># Read a textfile
./bin/NotesCLI read<filename># Update a textfile
./bin/NotesCLI update <filename># Delete a textfile
./bin/NotesCLI delete <filename>The system organizes textfile into these categories:
notes- For general notes and todoslogs- For logs and records
There are two ways to create textfile:
a. Interactive Mode:
./bin/NotesCLI create notes todo.txt
# Then type your content and press Ctrl+D when finishedTo read any textfile:
./bin/NotesCLI read notes todo.txtWhen you update a textfile, the old version is automatically saved in the versions directory:
a. Interactive Mode:
./bin/NotesCLI update todo.txt
# Enter new content and press Ctrl+D when finishedThe old version will be saved as: data/versions/notes_YYYYMMDD_HHMMSS_todo.txt
To delete a textfile (will ask for confirmation):
./bin/NotesCLI delete todo.txtThe system maintains a complete history of all operations in data/logs/history.txt. Each operation is logged with:
- Timestamp:
[YYYY-MM-DD HH:MM:SS] - Operation Type:
CREATE,READ,UPDATE,DELETE, orCLEAN-DOCS - File Path or Operation Details
Example log entries:
[2025-05-24 20:55:56] CREATE: notes/todo.txt
[2025-05-24 20:56:07] READ: notes/todo.txt
[2025-05-24 20:56:15] UPDATE: notes/todo.txt
[2025-05-24 20:56:19] DELETE: notes/todo.txt
[2025-05-24 21:00:00] CLEAN-DOCS: All textfiles cleared (notes, recipes, versions)
To view the operation history:
cat data/logs/history.txt- All textfile updates are automatically versioned
- Old versions are stored in
data/versions/ - Version files are named using the format:
category_YYYYMMDD_HHMMSS_filename - You can access old versions directly in the versions directory
- Creating and managing a recipe:
# Create a new recipeecho"Pasta Recipe:1. Boil water2. Add pasta3. Cook for 10 minutes"| ./bin/NotesCLI create recipes pasta.txt
# Read the recipe
./bin/NotesCLI read recipes pasta.txt
# Update the recipe (old version will be saved automatically)echo"Improved Pasta Recipe:1. Boil water with salt2. Add pasta3. Cook for 8-10 minutes4. Add olive oil"| ./bin/NotesCLI update recipes pasta.txt- Managing a todo list:
# Create todo listecho"1. Buy groceries2. Call mom3. Study C programming"| ./bin/NotesCLI create notes todo.txt
# Update with completed itemsecho"1. Buy groceries - DONE2. Call mom3. Study C programming4. Go to gym"| ./bin/NotesCLI update notes todo.txt- Filenames can only contain:
- Letters (a-z, A-Z)
- Numbers (0-9)
- Dots (.)
- Hyphens (-)
- Underscores (_)
- Directory traversal is not allowed in filenames
- Maximum input size for textfile content is 4KB
The system provides clear error messages for:
- Invalid commands
- Invalid categories
- Invalid filenames
- File operation failures
- Memory allocation failures
- Version backup failures
- Logging failures