restructuring
This commit is contained in:
35
main.py
35
main.py
@@ -1,39 +1,12 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import argparse
|
|
||||||
from lib.DataStore import DataStore
|
|
||||||
from lib.TimeSlot import TimeSlot
|
|
||||||
from lib.ui import convert_to_table
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from model.DataStore import DataStore
|
||||||
|
from model.TimeSlot import TimeSlot
|
||||||
|
|
||||||
def create_parser():
|
from util.views import convert_to_table
|
||||||
# Create the top-level parser
|
from util.parser import create_parser
|
||||||
parser = argparse.ArgumentParser(description="Time tracker.")
|
|
||||||
subparsers = parser.add_subparsers(dest="command", help="Sub-command help")
|
|
||||||
|
|
||||||
# Create the parser for the "ls" command
|
|
||||||
_ = subparsers.add_parser("ls", help="List all events.")
|
|
||||||
|
|
||||||
# Create the parser for the "ps" command
|
|
||||||
_ = subparsers.add_parser("ps", help="Show the currently running event.")
|
|
||||||
|
|
||||||
# Create the parser for the "add" command
|
|
||||||
parser_add = subparsers.add_parser("add", help="Adding a new event.")
|
|
||||||
parser_add.add_argument("name", help="Name of the event")
|
|
||||||
parser_add.add_argument("-s", "--start", help="Start datetime (default now)")
|
|
||||||
parser_add.add_argument("-e", "--end", help="End datetime")
|
|
||||||
|
|
||||||
# Create the parser for the "start" command
|
|
||||||
parser_start = subparsers.add_parser("start", help="Starting a new event.")
|
|
||||||
parser_start.add_argument("name", help="Name of the event")
|
|
||||||
parser_start.add_argument("-s", "--start", help="Start datetime (default now)")
|
|
||||||
|
|
||||||
# Create the parser for the "end" command
|
|
||||||
parser_end = subparsers.add_parser("end", help="Ending the current event.")
|
|
||||||
parser_end.add_argument("-e", "--end", help="End datetime")
|
|
||||||
|
|
||||||
return parser
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
31
util/parser.py
Normal file
31
util/parser.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
|
def create_parser():
|
||||||
|
# Create the top-level parser
|
||||||
|
parser = argparse.ArgumentParser(description="Time tracker.")
|
||||||
|
subparsers = parser.add_subparsers(dest="command", help="Sub-command help")
|
||||||
|
|
||||||
|
# Create the parser for the "ls" command
|
||||||
|
_ = subparsers.add_parser("ls", help="List all events.")
|
||||||
|
|
||||||
|
# Create the parser for the "ps" command
|
||||||
|
_ = subparsers.add_parser("ps", help="Show the currently running event.")
|
||||||
|
|
||||||
|
# Create the parser for the "add" command
|
||||||
|
parser_add = subparsers.add_parser("add", help="Adding a new event.")
|
||||||
|
parser_add.add_argument("name", help="Name of the event")
|
||||||
|
parser_add.add_argument("-s", "--start", help="Start datetime (default now)")
|
||||||
|
parser_add.add_argument("-e", "--end", help="End datetime")
|
||||||
|
|
||||||
|
# Create the parser for the "start" command
|
||||||
|
parser_start = subparsers.add_parser("start", help="Starting a new event.")
|
||||||
|
parser_start.add_argument("name", help="Name of the event")
|
||||||
|
parser_start.add_argument("-s", "--start", help="Start datetime (default now)")
|
||||||
|
|
||||||
|
# Create the parser for the "end" command
|
||||||
|
parser_end = subparsers.add_parser("end", help="Ending the current event.")
|
||||||
|
parser_end.add_argument("-e", "--end", help="End datetime")
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from .TimeSlot import TimeSlot
|
from model.TimeSlot import TimeSlot
|
||||||
|
|
||||||
|
|
||||||
def convert_to_table(time_slot_list: list[TimeSlot]):
|
def convert_to_table(time_slot_list: list[TimeSlot]):
|
||||||
Reference in New Issue
Block a user