0x00. AirBnB clone - The console

Introduction

This is a team project to make a clone of AirBnb's console
We want to be able to manage the objects of our project:

  • Create a new object (ex: a new User or a new Place)
  • Retrieve an object from a file, a database etc…
  • Do operations on objects (count, compute stats, etc…)
  • Update attributes of an object
  • Destroy an object

Resources

General

Installation

git clone https://github.com/s-maarouf/AirBnB_clone.git

Execution

In interactive mode

$ ./console.py
(hbnb) help

Documented commands (type help <topic>):
========================================
EOF  help  quit

(hbnb) 
(hbnb) 
(hbnb) quit
$

In 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) 
$

Commands usage

  • help: list available commands:
(hbnb) help

Documented commands (type help <topic>):
========================================
EOF  all  create  destroy  help  quit  show  update

(hbnb)

  • help <command>: prints command documentation
(hbnb) help <command>

example

(hbnb) help destroy
Deletes an instance
(hbnb)

  • create: to create a new instance:
(hbnb) create <class_name>

example

(hbnb) create BaseModel
73fea987-e376-4de8-9964-1f17c59737ca
(hbnb)

  • show: to show an instance informations:
(hbnb) show <class_name> <class_id>

example

(hbnb) show BaseModel 73fea987-e376-4de8-9964-1f17c59737ca
[BaseModel] (73fea987-e376-4de8-9964-1f17c59737ca) {'id': '73fea987-e376-4de8-9964-1f17c59737ca', 'created_at': datetime.datetime(2023, 7, 16, 22, 23, 37, 618037), 'updated_at': datetime.datetime(2023, 7, 16, 22, 23, 37, 618037)}
(hbnb)

  • destroy: to destroy an instance:
(hbnb) destroy <class_name> <class_id>

example

(hbnb) destroy BaseModel 73fea987-e376-4de8-9964-1f17c59737ca
(hbnb)

  • all: to show all instances based or not on the class name
(hbnb) all

example

(hbnb) all
[]
(hbnb) create BaseModel
f9f6c985-14d1-4d4f-be9e-c2c80594c33f
(hbnb) all
["[BaseModel] (f9f6c985-14d1-4d4f-be9e-c2c80594c33f) {'id': 'f9f6c985-14d1-4d4f-be9e-c2c80594c33f', 'created_at': datetime.datetime(2023, 7, 16, 22, 30, 25, 505852), 'updated_at': datetime.datetime(2023, 7, 16, 22, 30, 25, 505852)}"]
(hbnb) create User
97763dfd-9521-46fb-bd2a-af570cfaf29b
(hbnb) all
["[BaseModel] (f9f6c985-14d1-4d4f-be9e-c2c80594c33f) {'id': 'f9f6c985-14d1-4d4f-be9e-c2c80594c33f', 'created_at': datetime.datetime(2023, 7, 16, 22, 30, 25, 505852), 'updated_at': datetime.datetime(2023, 7, 16, 22, 30, 25, 505852)}", "[User] (97763dfd-9521-46fb-bd2a-af570cfaf29b) {'id': '97763dfd-9521-46fb-bd2a-af570cfaf29b', 'created_at': datetime.datetime(2023, 7, 16, 22, 30, 30, 855188), 'updated_at': datetime.datetime(2023, 7, 16, 22, 30, 30, 855188)}"]
(hbnb)

  • update: to update an instance by adding or updating attribute
(hbnb) update <class_name> <class_id> <attribute name> "<attribute value>"

example

(hbnb) update User 97763dfd-9521-46fb-bd2a-af570cfaf29b first_name "SMAAROUF"
(hbnb) show User 97763dfd-9521-46fb-bd2a-af570cfaf29b
[User] (97763dfd-9521-46fb-bd2a-af570cfaf29b) {'id': '97763dfd-9521-46fb-bd2a-af570cfaf29b', 'created_at': datetime.datetime(2023, 7, 16, 22, 30, 30, 855188), 'updated_at': datetime.datetime(2023, 7, 16, 22, 30, 30, 855188), 'first_name': '"SMAAROUF"'}
(hbnb)

  • count: to count the number of instances of a class
(hbnb) count <class_name>

example

(hbnb) create City
4e01c33e-2564-42c2-b61c-17e512898bad
(hbnb) create City
e952b772-80a5-41e9-b728-6bc4dc5c21b4
(hbnb) count City
2
(hbnb)

  • quit: to quit the console:
(hbnb) quit
$

  • EOF: exit the program using EOF
(hbnb) EOF

$

Author's notes:

This project was made by @s-maarouf and @ABDE-LKADER