Skip to content

Commit

Permalink
feat(docs): add LICENSE file and enhance README with usage examples a…
Browse files Browse the repository at this point in the history
…nd command reference
  • Loading branch information
TheFoxKD committed Nov 23, 2024
1 parent 7ef9fc8 commit f2ad9c4
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 2 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
97 changes: 95 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,105 @@ cd book-manager-sys
pip install -r requirements.txt
```

## Usage
## 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
Expand Down

0 comments on commit f2ad9c4

Please sign in to comment.