Skip to content

Commit 24ec5d0

Browse files
committed
'simple_notes_app.py' app with 'README.md' file added successfully
1 parent bf978d5 commit 24ec5d0

File tree

2 files changed

+153
-0
lines changed

2 files changed

+153
-0
lines changed

simple_notes_app/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# 📝 Simple CLI Notes App
2+
3+
Welcome to the **My Notes App**, a simple, user-friendly command-line interface (CLI) application written in Python that allows you to:
4+
5+
- 🧾 Add new notes (one line at a time)
6+
- 👓 View saved notes
7+
- 🧹 Clear all notes with confirmation
8+
- 🔁 Navigate seamlessly with menu prompts
9+
10+
---
11+
12+
## 📌 Features
13+
14+
| Feature | Description |
15+
|--------------|--------------------------------------------------|
16+
| Add Notes | Easily add single-line notes via CLI |
17+
| View Notes | View your saved notes in a clean, readable way |
18+
| Clear Notes | Securely clear all notes after confirmation |
19+
| Interactive | Interactive menus for smooth navigation |
20+
| Persistent | Notes saved in a `.txt` file locally |
21+
22+
---
23+
24+
## 🚀 Getting Started
25+
26+
### 📦 Requirements
27+
28+
- Python 3.x
29+
- Basic command line knowledge
30+
31+
---
32+
33+
### 🔧 Installation
34+
35+
```bash
36+
# Clone this repository
37+
git clone https://github.com/your-username/cli-notes-app.git
38+
39+
# Navigate to the directory
40+
cd cli-notes-app
41+
42+
# Run the app
43+
python notes_app.py
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# ------------------------------------------------------------/
2+
# ------------------------------------------------------------/
3+
# Combining it into one CLI Program
4+
print('|-----------------------------------------|')
5+
6+
# Function to take 'user_choice' as a input
7+
def user_choices():
8+
print('|-----------------------------------------|')
9+
print("📚 MY NOTES APP\n")
10+
print("Press 1: Adding New Notes!")
11+
print("Press 2: Viewing Notes!")
12+
print("Press 3: Clear Notes!")
13+
14+
# input 'user_choice' with error handling block
15+
try:
16+
user_choice = int(input())
17+
except TypeError as e:
18+
print("Something went wrong!\nError: {}".format(e))
19+
20+
return user_choice
21+
22+
# Function to ask user to (Continue/Exit)
23+
def process_termination():
24+
terminate_process = input("Continue Adding New Notes? (y/n)").lower()
25+
if terminate_process in ['n', 'no']:
26+
print("Exiting The app...\n\n")
27+
return True
28+
else:
29+
return False
30+
31+
32+
# Function to adding new notes
33+
def add_notes():
34+
# Creating loop untill user want to exit
35+
while True:
36+
# Taking input notes from user
37+
notes_contents = input("Start typing to add new notes...\nREMEMBER: Add single line at a time!\n")
38+
39+
# Appending notes to a file
40+
with open('my_simple_notes_app_file.txt', 'a') as file:
41+
file.write(notes_contents + '\n')
42+
print("Your notes saved successfully!\n\n")
43+
44+
if process_termination:
45+
break
46+
47+
# Function to view & read notes
48+
def read_notes():
49+
# Reading from file
50+
with open('my_simple_notes_app_file.txt', 'r') as file:
51+
reading_notes = file.read()
52+
if len(reading_notes.strip()) != 0:
53+
print('|-----------------------------------------|')
54+
print('|📚📚📚📚📚📚📚📚📚📚📚📚📚📚|')
55+
print("Your Notes:\n", reading_notes)
56+
else:
57+
print("Error! Notes empty already...\n")
58+
59+
# Function to clear notes
60+
def clear_notes():
61+
62+
clear_status = None
63+
while True:
64+
clear_status = input("Are you sure to clear the notes? (y/n): ").lower()
65+
if clear_status not in ['y', 'yes', 'n', 'no']:
66+
print("Error: Incorrect input! Please try again...\n")
67+
else:
68+
break
69+
70+
if clear_status == 'y' or clear_status == 'yes':
71+
# check whether notes not empty already
72+
with open('my_simple_notes_app_file.txt', 'r') as file:
73+
saved_notes = file.read()
74+
if len(saved_notes.strip()) != 0:
75+
# If not empty, write mode will auto clear the contents
76+
with open('my_simple_notes_app_file.txt', 'w') as file:
77+
print("Your notes has been cleared successfully!\n")
78+
else:
79+
print("Error! Notes empty already...\n")
80+
else:
81+
print("Your notes are still safe")
82+
print('|-----------------------------------------|')
83+
84+
# Function to ask to user to (Continue/Exit)
85+
def main_menu():
86+
user_menu_choice = input("Got to Main Menu? (y/n)").lower()
87+
if user_menu_choice in ['n', 'no', 'nope']:
88+
print("Exiting the app...")
89+
print('|-----------------------------------------|')
90+
return True
91+
92+
def main():
93+
while True:
94+
user_choice = user_choices()
95+
if user_choice == 1:
96+
add_notes()
97+
elif user_choice == 2:
98+
read_notes()
99+
elif user_choice == 3:
100+
clear_notes()
101+
else:
102+
print("Incorrect input! Please try again...")
103+
104+
if main_menu():
105+
break
106+
107+
108+
109+
if __name__ == "__main__": # Checks if this script is being run directly (not imported as a module)
110+
main() # Calls the main() function to start the Notes App

0 commit comments

Comments
 (0)