diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..52daeeb Binary files /dev/null and b/.DS_Store differ diff --git a/.github/.DS_Store b/.github/.DS_Store new file mode 100644 index 0000000..a19f97e Binary files /dev/null and b/.github/.DS_Store differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c13f991 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 + +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. diff --git a/README.md b/README.md index 53f49d1..6190f46 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,109 @@ cd book-manager-sys pip install -r requirements.txt ``` -## Usage +> **Note on dependencies**: While the core business logic has no external dependencies, we use the Rich library +> for enhanced CLI output formatting and better user experience. This design choice separates presentation concerns +> from core functionality. + +## Usage Examples + +> **Note**: All commands must be run from the root directory of the project (book-manager-sys) using the `-m` flag. + +### Basic Usage ```bash -python src/main.py +# Show help and available commands +python -m src.cli.app + +# Add a new book +python -m src.cli.app add "The Art of Computer Programming" "Donald Knuth" 1968 + +# List all books +python -m src.cli.app list + +# Delete a book by ID +python -m src.cli.app delete book_1633024800.123456 + +# Search for books +python -m src.cli.app search --title "Computer" # Search by title +python -m src.cli.app search --author "Knuth" # Search by author +python -m src.cli.app search --year 1968 # Search by year + +# Change book status +python -m src.cli.app status book_1633024800.123456 borrowed # Mark as borrowed +python -m src.cli.app status book_1633024800.123456 available # Mark as available ``` +### Detailed Command Reference + +1. **Adding Books** + ```bash + # Basic add command + python -m src.cli.app add "Clean Code" "Robert C. Martin" 2008 + + # Example with a legendary programming book + python -m src.cli.app add "Design Patterns: Elements of Reusable Object-Oriented Software" "Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides" 1994 + ``` + - Titles and authors with spaces must be enclosed in quotes + - Year must be a valid number + - Books are automatically assigned a unique ID, e.g., book_1633024800.123456 + +2. **Listing Books** + ```bash + # List all books + python -m src.cli.app list + ``` + - Displays ID, title, author, year, and status + - Books are sorted by ID by default + +3. **Searching Books** + ```bash + # Search by title (partial match) + python -m src.cli.app search --field title "Patterns" + + # Search by author (partial match) + python -m src.cli.app search --field author "Martin" + + # Search by exact year + python -m src.cli.app search --field year 2008 + + ``` + - Searches are case-insensitive + - Partial matches work for title and author + - Year must be an exact match + +4. **Managing Book Status** + ```bash + # Mark book as borrowed + python -m src.cli.app status book_1633024800.123456 borrowed + + # Mark book as available + python -m src.cli.app status book_1633024800.123456 available + ``` + - Valid statuses are: available and borrowed + - Requires a valid book ID + +5. **Deleting Books** + ```bash + # Delete by ID + python -m src.cli.app delete book_1633024800.123456 + ``` + - Deletion is permanent + - Requires a valid book ID + - Will fail if the ID doesn’t exist + +### Error Handling + +- Invalid commands show usage help +- Non-existent book IDs return appropriate error +- Invalid status values show valid options +- Missing required arguments prompt for correct usage + +### Data Storage + +- Books are stored in `data/books.json` +- File is created automatically on first run + ## Development ### Testing and Quality Assurance diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..325b1de Binary files /dev/null and b/src/.DS_Store differ