Welcome to the AirBnB Clone Console! This is the first step towards building the AirBnB clone project, a full web application that mimics some functionalities of the popular accommodation rental platform, Airbnb.
Team project to build a clone of AirBnB.
The AirBnB Clone Console is a Python-based command-line interface (CLI) that allows you to manage AirBnB objects, such as users, states, cities, places, and more. With this console, you can perform various operations on these objects, including creating, retrieving, updating, and deleting them.
The console will perform the following tasks:
- create a new object
- retrive an object from a file
- do operations on objects
- destroy an object
- Style :
- Clone this GitHub repository to your local machine.
git clone https://github.com/nuuxcode/AirBnB-Clone.git
- Navigate to the project directory.
cd AirBnB-Clone
- Execute the console.
./console.py
Interactive mode
$ ./console.py
(hbnb) help
Documented commands (type help <topic>):
========================================
EOF help quit
(hbnb)
(hbnb)
(hbnb) quit
$
Non Interactive mode
$ echo "help" | ./console.py
(hbnb)
Documented commands (type help <topic>):
========================================
EOF help quit
(hbnb)
$
$ cat test_help
help
$
$ cat test_help | ./console.py
(hbnb)
Documented commands (type help <topic>):
========================================
EOF help quit
(hbnb)
$
- Start the console in interactive mode:
$ ./console.py
(hbnb)- Use help to see the available commands:
(hbnb) help
Documented commands (type help <topic>):
========================================
EOF all count create destroy help quit show update
(hbnb)- Quit the console:
(hbnb) quit
$- create
Creates a new instance of a given class. The class' ID is printed and the instance is saved to the file file.json.
(hbnb) create BaseModel
57262839-51d7-4a9a-93e2-35ed8e91d823
$- show
Deletes an instance of a given class with a given ID. Update the file.json
(hbnb) show BaseModel 57262839-51d7-4a9a-93e2-35ed8e91d823
[BaseModel] (57262839-51d7-4a9a-93e2-35ed8e91d823) {'id': '57262839-51d7-4a9a-93e2-35ed8e91d823', 'created_at': datetime.datetime(2023, 8, 13, 14, 19, 19, 412265), 'updated_at': datetime.datetime(2023, 8, 13, 14, 19, 19, 412357)}
(hbnb)
(hbhb)- all
Prints all string representation of all instances of a given class. If no class is passed, all classes are printed.
(hbnb) all
[BaseModel] (57262839-51d7-4a9a-93e2-35ed8e91d823) {'id': '57262839-51d7-4a9a-93e2-35ed8e91d823', 'created_at': datetime.datetime(2023, 8, 13, 14, 19, 19, 412265), 'updated_at': datetime.datetime(2023, 8, 13, 14, 19, 19, 412357)}
(hbnb) all BaseModel
[BaseModel] (57262839-51d7-4a9a-93e2-35ed8e91d823) {'id': '57262839-51d7-4a9a-93e2-35ed8e91d823', 'created_at': datetime.datetime(2023, 8, 13, 14, 19, 19, 412265), 'updated_at': datetime.datetime(2023, 8, 13, 14, 19, 19, 412357)}- destroy
Deletes an instance of a given class with a given ID. Update the file.json
(hbnb) destroy
** class name missing **
(hbnb) destroy BaseModel
** instance id missing **
(hbnb) destroy BaseModel 57262839-51d7-4a9a-93e2-35ed8e91d823
(hbnb) all
[]- count
Prints the number of instances of a given class.
(hbnb) create User
ce5f7ac5-4b2e-4c90-933d-6c78e69ab1c7
(hbnb) create User
dd697519-4ac9-42e0-80e2-fa7b3ac61193
(hbnb) create User
52c4036b-f018-49d0-8d93-d7a2d56bcdad
(hbnb) count User
3- unittest module
- File extension
.py - Files and folders star with
test_ - Organization:for
models/base.py, unit tests in:tests/test_models/test_base.py - Execution command:
python3 -m unittest discover tests - or:
python3 -m unittest tests/test_models/test_base.py
echo "python3 -m unittest discover tests" | bashTo run the tests in non-interactive mode, and discover all the test, you can use the command:
python3 -m unittest discover testsThis project is licensed under the MIT License - see the LICENSE file for details.