2024-06-19 14:55:39 +02:00
|
|
|
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")
|
2024-06-19 22:53:43 +02:00
|
|
|
parser_add.add_argument("-s", "--start", required=True, help="Start datetime (default now)")
|
|
|
|
|
parser_add.add_argument("-e", "--end", required=True, help="End datetime")
|
2024-06-19 14:55:39 +02:00
|
|
|
|
|
|
|
|
# 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")
|
|
|
|
|
|
2025-11-13 19:04:55 +01:00
|
|
|
# Create the parser for the "acc" command
|
|
|
|
|
parser_end = subparsers.add_parser("acc", help="Accumulate the duration of events.")
|
|
|
|
|
parser_end.add_argument("query", help="The regex matching for the name of the event.")
|
|
|
|
|
|
2024-06-19 14:55:39 +02:00
|
|
|
return parser
|