Code Monkey home page Code Monkey logo

holbertonschool-airbnb_clone's Introduction

hbnb

Holberton AirBnB Clone - The Console

This is the first part of a six part series of making a simple copy of the AirBnB website. This project will be completed over four months as part of our second trimester for Holberton Tulsa. Below we will have more of a description of the project and examples of how to use our console. consoleairbnb projectconsole

How to open our console

The console can be use in interactive or non-interactive mode. By entering ./console.py in the terminal a prompt will open up where the user can enter various commands to be executed.

Interactive Mode:

Screenshot 2023-02-05 195845

Non-Interactive Mode:

Screenshot 2023-02-05 200301
Exiting the console is as easy as Ctrl+D or the EOF command.

Class Info:

BaseModel User State City Place Review Amenity FileStorage
Defined In models/base_model.py models/user.py models/state.py models/city.py models/place.py models/review.py models/amenity.py models/engine/file_storage.py
Inherits From N/A BaseModel BaseModel BaseModel BaseModel BaseModel BaseModel N/A
Methods (Pub / Pri) str(), save(), to_dict() Pub Inh Inh Inh Inh Inh Inh all(), new(obj), save(), reload() Pub

Console.py do_{{command}} descriptions & usage:

Command / Usage Descriptions
quit returns true, breaking cmdloop
EOF (Ctrl+D) prints goodbye msg to SO, then breaks loop
create {{class name}} creates an instance of specified class
show {{class name}} {{instance}} prints str rep of class instance given class & id
destroy {{class name}} {{instance}} destroy specified instance of class
all {{class name}} prints str rep of all class instances in mem
update {{class name}} {{instance}} {{attribute}} "{{value}}" updates value of instance attribute in mem

Console.py examples:

**WARNING:** Since BaseModel classes have their instance ids instantiated via uuid4() (universally unique identifier) there's almost no chance that the instance(s) you generate locally will have the same id(s) as the following tutorial.

First run the console from the repo's base directory with:

./console.py

After this a (hbnb) prompt should be printed to standard out, and the command loop started.

Now you can use the built-in console functionality! To show all instances of State for example, you could use:

all State

but alas, there might not be any states prepopulated, but that's okay since youc an make one with...

create State

after which the instance ID of your newly created State should be printed to standard out. repeating this a few times then re-running the all State command should produce a list of all the state instances!

Now try updating the name of a state instance with... update!

update State 16360b87-6657-45dc-acbd-d3628c322493 name "Oklahoma"

and let's also give the other example states names...

update State f8377c68-8c8e-4a8d-887e-c575639f7cba name "Texas"
update State bd4d4249-b710-4d6a-b197-4919f77c4145 name "Colorado"

but what if we one day decide Texas sucks? well we can delete it like this:

destroy State f8377c68-8c8e-4a8d-887e-c575639f7cba

now if we try

show State f8377c68-8c8e-4a8d-887e-c575639f7cba

we'll see the "** no instance found **" error message! we can confirm the good states still exist with a quick

all State

then exit the console with the built in quit:

quit

Console.py Interactive Exit Conditions

  • 1. It receives a SIGTERM (Ctrl + D) EOF signal, causing a controlled shutdown
  • 2. It receives a SIGKILL signal, whereafter undefined behavior may transpire
  • 3. The built-in exit method 'quit' is used, also causing a controlled exit
  • 4. A fatal program error occurs, and is most likely printed to stderr

Unit Testing:

Included test modules exist in the project's 'tests' directory and are discoverable with command:

python3 -m unittest discover tests

To-Do/WIP ... currently console.py does not have any associated automatable testing.

Authors:

Heather Hayes
Screenshot_20230205_081038

Chris Stamper
Screenshot_20230205_081012

holbertonschool-airbnb_clone's People

Contributors

zerodaypoke avatar hayes28 avatar

Stargazers

 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.