-
Notifications
You must be signed in to change notification settings - Fork 0
/
journal.py
72 lines (49 loc) · 1.53 KB
/
journal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
Entry point module that consist of all the CLI commands
"""
import typer
from cli import handlers as handler
from cli import utils as util
# from .cli import handlers as handler
app = typer.Typer()
# def main():
# print("Hello World")
# Add imported commands to the main Typer application instance
@app.command(name="add", short_help="Add a new entry to your journal.")
def add(): # Add title as an argument
"""
Adds a new journal entry.
Prompts the user to enter a title and a journal entry.
Sends the data to the add handler to be added to the file.
Returns:
None
"""
title = typer.prompt("Please enter a title")
entry = typer.prompt("Please enter your journal entry")
confirm = typer.confirm("Do you want to add this entry?")
if confirm:
# Send data to add handler
handler.add_entry_to_file(
entry_obj={"Title": title, "Entry": entry}
) # Pass entries_file argument
else:
typer.echo("Entry Discarded!")
# @app.command()
# def view(name: str):
# typer.echo(f"Hello {name}")
# @app.command()
# def export(name: str):
# typer.echo(f"Hello {name}")
# @app.command()
# def search(keyword: str):
# handler.search_entries(keyword)
# @app.command()
# def delete(name: str):
# typer.echo(f"Hello {name}")
# @app.command()
# def edit(name: str):
# typer.echo(f"Hello {name}")
if __name__ == "__main__":
# Check if first entry, if so create the dir and file.
util.check_entries_dir() # pylint: disable=E1120
app()