https://github.com/mohabdo21/library_cli
try to learn python cmd module by build a library CLI
https://github.com/mohabdo21/library_cli
Last synced: 3 months ago
JSON representation
try to learn python cmd module by build a library CLI
- Host: GitHub
- URL: https://github.com/mohabdo21/library_cli
- Owner: Mohabdo21
- Created: 2024-01-06T23:01:44.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-25T02:23:05.000Z (11 months ago)
- Last Synced: 2025-01-18T00:13:25.359Z (5 months ago)
- Language: Python
- Size: 237 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: historyBookList.txt
Awesome Lists containing this project
README
# Library Management System
This project provides a simple and interactive shell for managing different sections of a library. It allows users to add, lookup, and display books in the Biology, Economy, and History sections.
## Files
The project consists of two main Python files:
1. `library.py`: This module defines a `Library` class and several subclasses for different sections of a library. Each class provides methods for managing books in that section.
2. `script.py`: This script provides an interactive shell for managing different sections of a library. It allows the user to add, lookup, and display books in the Biology, Economy, and History sections.
## Classes
### Library
The `Library` class represents a library. It provides the following methods:
- `load_books()`: Load books from a file.
- `save_books()`: Save books to a file.
- `add_book()`: Add a book to the library.
- `lookup_book()`: Search for a book in the library.
- `display_books()`: Display all books in the library.### Biology, Economy, History
These classes represent the Biology, Economy, and History sections in the library. They are subclasses of the `Library` class and inherit all its methods.
## LibraryShell
The `LibraryShell` class provides an interactive shell for managing different sections in the library. It provides the following commands:
- `add SECTION`: Add a new book to the selected section.
- `lookup SECTION`: Search for a book in the selected section.
- `display SECTION`: Display all books available in the selected section.
- `exit`: Exit the program.## Usage
To start the interactive shell, run the `script.py` script:
```
bash
./script.py
```Then, you can use the add, lookup, display, and exit commands to manage the library.
Use `help` or `?` with command name to know more about the command.```
$ ./script.py
Welcome to the library shell, Type help or ? to list commands.(library) help
Documented commands (type help ):
========================================
add display exit help lookup(library) add biology
Adding a Book to the Section Biology
Enter The name of The Book: Guns, Germs, and Steel
Enter The name of The Author: Book by Jared Diamond
Enter The Number of The Pages: 480
(library) exit
Thank you For using library. Good Bye!
```Please review and comment. Let me know if you need further assistance! 😊