Skip to content

A command line interpreter(console) built to help perform opeations AirBnB objects and manipulate them

License

Notifications You must be signed in to change notification settings

Timadey/AirBnB_clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AirBnB Clone License: MIT

HBnB Logo

Contents

Description 📄

This is the first step towards building an AirBnB clone. A command line interpreter(console) is built to help create objects and manipulat AirBnB objects. The console has the ability to do the following:

  • 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

Technology used ⚙️

The console was developed in

  • Environment: Ubuntu 20.04LTS
  • Language: python3 (version 3.8.10)
  • Style guide: pycodestyle

Requirements 📝

  • Knowledge in python3
  • how to use a command line interpreter
  • Ubuntu 20.04, python3 and pep8 style corrector installed

Repo Contents 📋

This repository constains the following files:

File Description
AUTHORS Contains info about authors of the project
base_model.py Defines BaseModel class (parent class), and methods
user.py Defines subclass User
amenity.py Defines subclass Amenity
city.py Defines subclass City
place.py Defines subclass Place
review.py Defines subclass Review
state.py Defines subclass State
file_storage.py Creates new instance of class, serializes and deserializes data
console.py creates object, retrieves object from file, does operations on objects, updates attributes of object and destroys object
test_base_model.py unittests for base_model
test_user.py unittests for user
test_amenity.py unittests for amenity
test_city.py unittests for city
test_place.py unittests for place
test_review.py unittests for review
test_state.py unittests for state
test_file_storage.py unittests for file_storage
test_console.py unittests for console

Installation 🛠️

Clone the repository and run the console.py

$ git clone https://github.com/Timadey/AirBnB_clone.git
$ Cloning into 'AirBnB_clone'...
$ ......
$ ./console.py

Usage 🔧

Method Description
create Creates object of given class
show Prints the string representation of an instance based on the class name and id
all Prints all string representation of all instances based or not on the class name
update Updates an instance based on the class name and id by adding or updating attribute (save the change into the JSON file)
destroy Deletes an instance based on the class name and id (save the change into the JSON file)
count Retrieve the number of instances of a class
help Prints information about specific command
quit/ EOF Exit the program
Example
➜  AirBnB_clone git:(feature) ✗ ./console.py
Welcome to AirBnb clone console(CLI)
    This console helps to manipulate objects used in this project
    Source code: https://github.com/Timadey/AirBnB_clone.git
    Run `help` to show available command
    `help command` to show detailed usage of command

// Create new user object
(hbnb) create User
71d6e089-099c-4a7b-95c4-efcaff61cdd7

// Read that User object
(hbnb) show User 71d6e089-099c-4a7b-95c4-efcaff61cdd7
{'id': '71d6e089-099c-4a7b-95c4-efcaff61cdd7', 'created_at': '2022-09-03T21:40:07.723677', 'updated_at': '2022-09-03T21:40:07.723677', '__class__': 'User'}

// Update the User object
(hbnb) update User 71d6e089-099c-4a7b-95c4-efcaff61cdd7
** attribute name missing **
(hbnb) update User 71d6e089-099c-4a7b-95c4-efcaff61cdd7 name "Timadey"

// Check that update was done
(hbnb) show User 71d6e089-099c-4a7b-95c4-efcaff61cdd7
{'id': '71d6e089-099c-4a7b-95c4-efcaff61cdd7',
'created_at': '2022-09-03T21:40:07.723677',
'updated_at': '2022-09-03T21:42:01.196758',
 'name': 'Timadey', '__class__': 'User'}

// Read all objects
(hbnb) all
["[BaseModel] (72132fac-8071-4837-a82c-cd6ff6d77cef)
{'id': '72132fac-8071-4837-a82c-cd6ff6d77cef', 'created_at': datetime.datetime(2022, 8, 31, 22, 35, 47, 154823), 'updated_at': datetime.datetime(2022, 9, 2, 17, 18, 34, 396999),
'name': 'My_First_Model', 'my_number': 89, 'email': 18383.322, 'email_alias': '89'}", ...,
"[User] (71d6e089-099c-4a7b-95c4-efcaff61cdd7)
{'id': '71d6e089-099c-4a7b-95c4-efcaff61cdd7',
'created_at': datetime.datetime(2022, 9, 3, 21, 40, 7, 723677),
'updated_at': datetime.datetime(2022, 9, 3, 21, 40, 7, 723677)}"]

// Read all Users
(hbnb) all User
["[User] (6932c087-6d06-4821-9189-7ea19319163e)
{'id': '6932c087-6d06-4821-9189-7ea19319163e', 'created_at': datetime.datetime(2022, 9, 3, 20, 18, 4, 553033),
'updated_at': datetime.datetime(2022, 9, 3, 20, 18, 4, 553033)}", ..., "[User] (71d6e089-099c-4a7b-95c4-efcaff61cdd7)
{'id': '71d6e089-099c-4a7b-95c4-efcaff61cdd7', 'created_at': datetime.datetime(2022, 9, 3, 21, 40, 7, 723677),
'updated_at': datetime.datetime(2022, 9, 3, 21, 42, 1, 196758), 'name': 'Timadey'}"]

// Destroy User
(hbnb) destry User 71d6e089-099c-4a7b-95c4-efcaff61cdd7
*** Unknown syntax: destry User 71d6e089-099c-4a7b-95c4-efcaff61cdd7
(hbnb) destroy User 71d6e089-099c-4a7b-95c4-efcaff61cdd7

// Check that User was destroyed successfully
(hbnb) show User 71d6e089-099c-4a7b-95c4-efcaff61cdd7
** no instance found **

// Exit console using quit or CTRL-D
(hbnb) quit
Bye

Further information 📑

Each module and methods are well documented with docstrings. For further information and documentation visit python.org.

Authors 🖋️

About

A command line interpreter(console) built to help perform opeations AirBnB objects and manipulate them

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published