Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maincopy #22

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 14 additions & 168 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,172 +1,18 @@
# Phase 3 CLI+ORM Project Template
# Cars and Drivers Arcade Game

## Learning Goals
Choose your character! Then choose a car! Sound familiar? This is the beginning of most racing games. This CLI organizes the cars and drivers in a way that makes it easy to view all car options and which characters have chosen them.

- Discuss the basic directory structure of a CLI.
- Outline the first steps in building a CLI.
To run the CLI, install your pipenv and shell. Then type "python cli.py" to view the list of commands. From there it should be pretty easy to find what you're looking for! Below is a list of commands that can be performed when running the CLI.

---
0. Exit the program
1. LIST ALL car BRANDS
2. CREATE a New Car BRAND
3. DELETE an Existing Car BRAND
4. FIND Car BRAND by Name
5. LIST all BRANDS of a Specific Country
6. LIST all Existing DRIVERS
7. CREATE a New DRIVER
8. DELETE an existing DRIVER
9. FIND an existing DRIVER by name
10. List all DRIVERS of a specific BRAND #

## Introduction

You now have a basic idea of what constitutes a CLI. Fork and clone this lesson
for a project template for your CLI.

Take a look at the directory structure:

```console
.
├── Pipfile
├── Pipfile.lock
├── README.md
└── lib
├── models
│ ├── __init__.py
│ └── model_1.py
├── cli.py
├── debug.py
└── helpers.py
```

Note: The directory also includes two files named `CONTRIBUTING.md` and
`LICENSE.md` that are specific to Flatiron's curriculum. You can disregard or
delete the files if you want.

---

## Generating Your Environment

You might have noticed in the file structure- there's already a Pipfile!

Install any additional dependencies you know you'll need for your project by
adding them to the `Pipfile`. Then run the commands:

```console
pipenv install
pipenv shell
```

---

## Generating Your CLI

A CLI is, simply put, an interactive script and prompts the user and performs
operations based on user input.

The project template has a sample CLI in `lib/cli.py` that looks like this:

```py
# lib/cli.py

from helpers import (
exit_program,
helper_1
)


def main():
while True:
menu()
choice = input("> ")
if choice == "0":
exit_program()
elif choice == "1":
helper_1()
else:
print("Invalid choice")


def menu():
print("Please select an option:")
print("0. Exit the program")
print("1. Some useful function")


if __name__ == "__main__":
main()
```

The helper functions are located in `lib/helpers.py`:

```py
# lib/helpers.py

def helper_1():
print("Performing useful function#1.")


def exit_program():
print("Goodbye!")
exit()
```

You can run the template CLI with `python lib/cli.py`, or include the shebang
and make it executable with `chmod +x`. The template CLI will ask for input, do
some work, and accomplish some sort of task.

Past that, CLIs can be whatever you'd like, as long as you follow the project
requirements.

Of course, you will update `lib/cli.py` with prompts that are appropriate for
your application, and you will update `lib/helpers.py` to replace `helper_1()`
with a useful function based on the specific problem domain you decide to
implement, along with adding other helper functions to the module.

In the `lib/models` folder, you should rename `model_1.py` with the name of a
data model class from your specific problem domain, and add other classes to the
folder as needed. The file `lib/models/__init__.py` has been initialized to
create the necessary database constants. You need to add import statements to
the various data model classes in order to use the database constants.

You are also welcome to implement a different module and directory structure.
However, your project should be well organized, modular, and follow the design
principal of separation of concerns, which means you should separate code
related to:

- User interface
- Data persistence
- Problem domain rules and logic

---

## Updating README.md

`README.md` is a Markdown file that should describe your project. You will
replace the contents of this `README.md` file with a description of **your**
actual project.

Markdown is not a language that we cover in Flatiron's Software Engineering
curriculum, but it's not a particularly difficult language to learn (if you've
ever left a comment on Reddit, you might already know the basics). Refer to the
cheat sheet in this assignments's resources for a basic guide to Markdown.

### What Goes into a README?

This README serves as a template. Replace the contents of this file to describe
the important files in your project and describe what they do. Each Python file
that you edit should get at least a paragraph, and each function should be
described with a sentence or two.

Describe your actual CLI script first, and with a good level of detail. The rest
should be ordered by importance to the user. (Probably functions next, then
models.)

Screenshots and links to resources that you used throughout are also useful to
users and collaborators, but a little more syntactically complicated. Only add
these in if you're feeling comfortable with Markdown.

---

## Conclusion

A lot of work goes into a good CLI, but it all relies on concepts that you've
practiced quite a bit by now. Hopefully this template and guide will get you off
to a good start with your Phase 3 Project.

Happy coding!

---

## Resources

- [Markdown Cheat Sheet](https://www.markdownguide.org/cheat-sheet/)
114 changes: 103 additions & 11 deletions lib/cli.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,120 @@
# lib/cli.py

from models.brand import Brand
from helpers import (
exit_program,
helper_1
list_brands,
create_brand,
delete_brand,
find_brand_by_name,
list_brands_by_country,
create_driver,
list_drivers,
delete_driver,
find_driver_by_name,
list_drivers_by_brand,
find_brand_by_driver_name,
start_game,
)


def main():


print("----------------------------------")
print(" ")
print(" 🏁 FLATIRON ARCADE RACER 🏁 ")
print(" ")
print(" 🚕 🏎️💨 🚗 🚚 ")
print("----------------------------------")


while True:
menu()
choice = input("> ")
choice = input("Select an option (0-11): ")
if choice == "0":
exit_program()
elif choice == "1":
helper_1()
list_brands()
elif choice == "2":
create_brand()
elif choice == "3":
delete_brand()
elif choice == "4":
find_brand_by_name()
elif choice == "5":
list_brands_by_country()
elif choice == "6":
list_drivers()
elif choice == "7":
create_driver()
elif choice == "8":
delete_driver()
elif choice == "9":
find_driver_by_name()
elif choice == "10":
list_drivers_by_brand()
elif choice == "11":
find_brand_by_driver_name()
elif choice == "11":
start_game()
elif choice == "12":
else:
print("Invalid choice")

print("Invalid choice. Please select a valid option.")

def menu():
print("Please select an option:")
print("0. Exit the program")
print("1. Some useful function")
print("\nGET OUT THERE AND START RACING")
print("------------------------------------------")
print("0. 🚫Quit Game")
print("------------------------------------------")
print("1. 🏁 List all Cars")
print("------------------------------------------")
print("2. 🚀 Create a new Car")
print("------------------------------------------")
print("3. 🗑️ Delete an existing car brand")
print("------------------------------------------")
print("4. 🔍 Find a car brand by name")
print("------------------------------------------")
print("5. 🌍 List all brands of a specific country")
print("------------------------------------------")
print("6. 🚗 List all existing drivers")
print("------------------------------------------")
print("7. 🏎️ Create a new driver")
print("------------------------------------------")
print("8. 🗑️ Delete an existing driver")
print("------------------------------------------")
print("9. 🔍 Find an existing driver by name")
print("------------------------------------------")
print("10. 🏁List all drivers of a specific brand")
print("------------------------------------------")
print("------------------------------------------")
print("------------------------------------------")
print("11. \033[1m\033[33m--------------- START GAME ---------------\033[0m")
print("------------------------------------------")
print("------------------------------------------")


def start_game():
print("Welcome to the START GAME page.")
while True:
start_game_menu()
choice = input("Choose from the menu below:")

if choice == "0":
return # Return to the main menu
elif choice == "1":
list_drivers()
else:
print("Invalid choice. Please select a valid option.")


def start_game_menu():
print("START GAME MENU")
print("------------------------------------------")
print("0. Return to main menu")
print("------------------------------------------")
print("1. PICK YOUR DRIVER")
print("------------------------------------------")



if __name__ == "__main__":
main()

Loading