Git Product home page Git Product logo

airbnb_clone's Introduction

0x00. AirBnB clone - The console

Description of the project:

This is the first full web application project for every software engineering trainee at Alx Africa.It is a hands-on practice showing the implementation of all the fundamental concepts covered in the Alx high-level programming track.

Description of the command interpreter:

This console is a command interpreter to manipulate data without a visual interface, like in a shell (perfect for development and debugging).

how to start it

  • Installation and execution ๐Ÿ”ง Clone the repository
$ git clone https://github.com/WalaEddine01/AirBnB_clone.git

Move in to the directory

$ cd AirBnB_clone

Execute the console file

/AirBnB_clone$ ./console.py

how to use it

console commands:

  • create : Creates a new instance of the class passed by argument.
  • show : Prints the string representation of an instance.
  • destroy : Deletes an instance that was already created.
  • all : Prints string representation of all instances or of all instances of a specified class.
  • update : Updates an instance attribute if exists otherwise create it.
  • help : Show all commands or display information about a specific command.
  • quit : Exit the console.
  • EOF : Exit the console.

Commands usage:

  • create : create <class_name>
  • show : show <class_name> <object_id> ; <class_name>.show(<object_id>)()
  • destroy : destroy <class_name> <object_id ; <class_name>.destroy(<object_id>)()
  • all : all <class_name> ; <class_name>.all()
  • update : update <class_name> <object_id> "" ; .update(<object_id>, , ) ; .update(<object_id>, )
  • help : help ; help <command_name>
  • quit : quit
  • EOF : EOF ; (ctrl + d)

Concepts:

* Python package

* cmd module

* Unit testing

* serialize and deserialize a Class

* JSON file

* datetime modual

* What is an UUID

* *args and **kwargs

Examples

Example 1: Using create, count and all commands

$ ./console.py
(hbnb) all
[]
(hbnb) create Place
482f60f3-ff1e-43c7-bb11-f8407b04dd69
(hbnb) create BaseModel
88f01e9a-98c0-43af-8c10-c35cadee1d5e
(hbnb) BaseModel.count()
1
(hbnb) all
["[Place] (482f60f3-ff1e-43c7-bb11-f8407b04dd69) {'id': '482f60f3-ff1e-43c7-bb11-f8407b04dd69', 'created_at': datetime.datetime(2023, 11, 14, 19, 59, 24, 576486), 'updated_at': datetime.datetime(2023, 11, 14, 19, 59, 24, 576530)}", "[BaseModel] (88f01e9a-98c0-43af-8c10-c35cadee1d5e) {'id': '88f01e9a-98c0-43af-8c10-c35cadee1d5e', 'created_at': datetime.datetime(2023, 11, 14, 20, 00, 30, 773211), 'updated_at': datetime.datetime(2023, 11, 14, 20, 00, 30, 773236)}"]
(hbnb)

Example 2: Using basic update with an Id and show command

(hbnb) update BaseModel 99f01e9a-99c0-42af-8c10-c35cadee1d8f first_name "Betty"
(hbnb) show BaseModel 99f01e9a-99c0-42af-8c10-c35cadee1d8f
[BaseModel] (99f01e9a-99c0-42af-8c10-c35cadee1d8f) {'id': '99f01e9a-99c0-42af-8c10-c35cadee1d8f', 'created_at': datetime.datetime(2023, 11, 14, 20, 00, 30, 773211), 'updated_at': datetime.datetime(2023, 11, 14, 20, 00, 30, 773236), 'first_name': 'Betty'}
(hbnb) Place.update("492f60f3-ff1e-43c7-bb11-f8407b04dd59", "first_name", "John")
(hbnb) show Place 492f60f3-ff1e-43c7-bb11-f8407b04dd59
[Place] (492f60f3-ff1e-43c7-bb11-f8407b04dd59) {'id': '492f60f3-ff1e-43c7-bb11-f8407b04dd59', 'created_at': datetime.datetime(2023, 11, 14, 20, 00, 24, 576486), 'updated_at': datetime.datetime(2023, 11, 14, 20, 00, 24, 576530), 'first_name': 'John'}

Example 3: Using update with a dictionary

(hbnb) BaseModel.update("99f01e9a-99c0-42af-8c10-c35cadee1d8f", {'first_name': "Petter", "age": 45})
(hbnb) show BaseModel 99f01e9a-99c0-42af-8c10-c35cadee1d8f
[BaseModel] (99f01e9a-99c0-42af-8c10-c35cadee1d8f) {'id': '99f01e9a-99c0-42af-8c10-c35cadee1d8f', 'created_at': datetime.datetime(2023, 11, 14, 20, 00, 30, 773211), 'updated_at': datetime.datetime(2023, 11, 14, 20, 00, 30, 773236), 'first_name': 'Petter', 'age': '45'}

Example 4: Using destroy and count command

(hbnb) BaseModel.destroy("99f01e9a-99c0-42af-8c10-c35cadee1d8f")
(hbnb) all
["[Place] (492f60f3-ff1e-43c7-bb11-f8407b04dd59) {'id': '492f60f3-ff1e-43c7-bb11-f8407b04dd59', 'created_at': datetime.datetime(2023, 11, 14, 20, 00, 24, 576486), 'updated_at': datetime.datetime(2023, 11, 14, 20, 00, 24, 576530), 'first_name': 'John'}"]
(hbnb) BaseModel.count()
0
(hbnb) quit
$

Example 5: Non - Interactive Mode

$ echo "create User" | ./console.py
(hbnb) 55b76419-6009-4b36-b88a-7c2930283f4a
$ echo "show User 55b76419-6009-4b36-b88a-7c2930283f4a" | ./console.py
(hbnb) [User] (55b76419-6009-4b36-b88a-7c2930283f4a) {'id': '55b76419-6009-4b36-b88a-7c2930283f4a', 'created_at': datetime.datetime(2023, 11, 14, 20, 37, 15, 575191), 'updated_at': datetime.datetime(2023, 11, 14, 20, 37, 15, 575237)}

Collaborators

Nadjib M Wala Eddine B
nadjib wala

Coded with

py

airbnb_clone's People

Contributors

walaeddine01 avatar nadjib-coder avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.