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
│ ├── recipes/ # Recipe textfile
│ ├── 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:
make
This will create the dms
executable in the bin
directory.
To clean the build files:
make clean
To clean all textfile while preserving history:
make clean-docs
This 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 DMS supports the following commands:
# Create a new textfile
./bin/dms create <category> <filename>
# Read a textfile
./bin/dms read <category> <filename>
# Update a textfile
./bin/dms update <category> <filename>
# Delete a textfile
./bin/dms delete <category> <filename>
The system organizes textfile into these categories:
recipes
- For storing cooking recipesnotes
- For general notes and todoslogs
- For logs and records
There are two ways to create textfile:
a. Interactive Mode:
./bin/dms create notes todo.txt
# Then type your content and press Ctrl+D when finished
b. Using Echo (for quick creation):
echo "My content here" | ./bin/dms create notes quick-note.txt
To read any textfile:
./bin/dms read notes todo.txt
When you update a textfile, the old version is automatically saved in the versions directory:
a. Interactive Mode:
./bin/dms update notes todo.txt
# Enter new content and press Ctrl+D when finished
b. Using Echo:
echo "Updated content" | ./bin/dms update notes todo.txt
The old version will be saved as: data/versions/notes_YYYYMMDD_HHMMSS_todo.txt
To delete a textfile (will ask for confirmation):
./bin/dms delete notes todo.txt
The 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 recipe
echo "Pasta Recipe:
1. Boil water
2. Add pasta
3. Cook for 10 minutes" | ./bin/dms create recipes pasta.txt
# Read the recipe
./bin/dms read recipes pasta.txt
# Update the recipe (old version will be saved automatically)
echo "Improved Pasta Recipe:
1. Boil water with salt
2. Add pasta
3. Cook for 8-10 minutes
4. Add olive oil" | ./bin/dms update recipes pasta.txt
- Managing a todo list:
# Create todo list
echo "1. Buy groceries
2. Call mom
3. Study C programming" | ./bin/dms create notes todo.txt
# Update with completed items
echo "1. Buy groceries - DONE
2. Call mom
3. Study C programming
4. Go to gym" | ./bin/dms 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