Skip to content

just337ine/AirBnB_clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

0x00. AirBnB Clone - The Console

Table of Contents

Description

The Airbnb Console Application is a command-line tool that allows you to interact with a collection of data models. These data models include BaseModel, User, State, City, Amenity, Place, and Review. The application provides a set of commands to create, read, update, and delete instances of these models, as well as other features like counting instances, retrieving all instances, and updating instances with dictionary representations.

Background Context

The goal is 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.

Command Interpreter

The command interpreter, implemented in the console.py file, is the core of this application. It provides an interactive shell that accepts user commands to perform various operations on the data models. Here's how to get started and use the command interpreter:

How to Start

To start the Airbnb Console Application, follow these steps:

  1. Clone the repository to your local machine:

    git clone https://github.com/ugwujustine/AirBnB_clone.git
  2. Change your current directory to the project folder:

    cd airbnb-console
  3. Run the command interpreter:

    ./console.py

You should now see a (hbnb) prompt, indicating that you are in the Airbnb Console.

Usage

The command interpreter supports various commands to manage and interact with the data models. Here are some of the available commands:

  • create <class_name>: Create a new instance of a class and print its unique ID.
  • show <class_name> <instance_id>: Display the string representation of an instance based on its class name and ID.
  • all [class_name]: Retrieve all instances of a class, or if a class name is provided, retrieve all instances of that class.
  • count <class_name>: Get the count of instances of a specific class.
  • update <class_name> <instance_id> <attribute_name> <attribute_value>: Update an instance's attribute.
  • destroy <class_name> <instance_id>: Delete an instance based on its class name and ID.
  • update <class_name> <instance_id> <dictionary_representation>: Update an instance based on a dictionary representation.

Examples

Here are some examples of how to use the Airbnb Console Application:

  • Create a new User instance:

    (hbnb) create User
  • Show details of a User instance with a specific ID (replace <instance_id> with the actual ID):

    (hbnb) show User <instance_id>
  • Retrieve all instances of the User class:

    (hbnb) all User
  • Count the number of instances of the User class:

    (hbnb) count User
  • Update a User instance's email attribute:

    (hbnb) update User <instance_id> email "new_email@example.com"
  • Delete a User instance:

    (hbnb) destroy User <instance_id>
  • Update a User instance using a dictionary representation:

    (hbnb) update User <instance_id> {"email": "new_email@example.com", "first_name": "Gift"}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published