AirBnB clone - The console

The project

The AirBnB clone (hbnb), is a project in which the students of Holberton deploy on a server a simple copy of the AirBnB website, in order to cover all fundamental concepts of the higher level programming track.

The web application is composed by:

  • A command interpreter to manipulate data without a visual interface, like in a Shell (perfect for development and debugging)

  • A website (the front-end) that shows the final product to everybody: static and dynamic

  • A database or files that store data (data = objects)

  • An API that provides a communication interface between the front-end and your data (retrieve, create, delete, update them)

The console

The console is a command line interpreter but limited to a specific use-case. In this case it will be able to manage the objects of our AirBnb clone 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

Execution (How to start it?)

The shell works like this in interactive mode:

$ ./console.py
(hbnb)

But also in non-interactive mode:

$ echo "help" | ./console.py
(hbnb)

How to use it?

NOTE: you can use the help option with all the commands implemented to see the respective documentation.

(hbnb) help

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

i.e.

(hbnb) help quit
Quit command to exit the program
  • quit and EOF to exit the program

i.e.

$ ./console.py
(hbnb) quit 
$
  • create: Creates a new instance of BaseModel, saves it (to the JSON file) and prints the id.

Syntax: $ create [CLASS]

i.e.

(hbnb) create BaseModel
49faff9a-6318-451f-87b6-910505c55907
  • show: Prints the string representation of an instance based on the class name and id.

Syntax: $ show [CLASS] [ID]

i.e.

(hbnb) show BaseModel 49faff9a-6318-451f-87b6-910505c55907
[BaseModel] (49faff9a-6318-451f-87b6-910505c55907) {'created_at': datetime.datetime(2017, 10, 2, 3, 10, 25, 903293), 'id': '49faff9a-6318-451f-87b6-910505c55907', 'updated_at': datetime.datetime(2017, 10, 2, 3, 10, 25, 903300)}
  • destroy: Deletes an instance based on the class name and id (save the change into the JSON file).

Syntax: $ destroy [CLASS] [ID]

i.e.

(hbnb) destroy BaseModel 49faff9a-6318-451f-87b6-910505c55907
  • all: Prints all string representation of all instances based or not on the class name.

Syntax: $ all [CLASS] or $ all

i.e.

(hbnb) all BaseModel
["[BaseModel] (2dd6ef5c-467c-4f82-9521-a772ea7d84e9) {'id': '2dd6ef5c-467c-4f82-9521-a772ea7d84e9', 'created_at': datetime.datetime(2017, 10, 2, 3, 11, 23, 639717), 'updated_at': datetime.datetime(2017, 10, 2, 3, 11, 23, 639724)}", "[BaseModel] (49faff9a-6318-451f-87b6-910505c55907) {'first_name': 'Betty', 'id': '49faff9a-6318-451f-87b6-910505c55907', 'created_at': datetime.datetime(2017, 10, 2, 3, 10, 25, 903293), 'updated_at': datetime.datetime(2017, 10, 2, 3, 11, 3, 49401)}"]
  • update: Updates an instance based on the class name and id by adding or updating attribute (save the change into the JSON file).

Syntax: $ update [CLASS] [ID] [ATTRIBUTE] [VALUE]

i.e.

(hbnb) update BaseModel 49faff9a-6318-451f-87b6-910505c55907 first_name "Betty"

If a command is missing an argument or it does not exist, a message will be displayed:

i.e.

(hbnb) all MyModel
** class doesn't exist **
(hbnb) destroy
** class name missing **

Authors

  • Emma Juliana Gachancipa Castelblanco... alt textalt textalt textalt text

  • Juan Sebastian Montealegre Calle............. alt textalt textalt textalt text