diff --git a/src/class_todo.py b/src/class_todo.py index 94cbbda..41097d6 100644 --- a/src/class_todo.py +++ b/src/class_todo.py @@ -1,13 +1,7 @@ # pylint: disable=global-statement, missing-class-docstring # pylint: disable=missing-function-docstring, missing-module-docstring -INDENT = 0 - - -def init(indent): - global INDENT - INDENT = indent - +from src.get_args import INDENT class Todo: def __init__(self, text: str = "") -> None: diff --git a/src/get_args.py b/src/get_args.py index 94fc2de..d697ea6 100644 --- a/src/get_args.py +++ b/src/get_args.py @@ -7,64 +7,20 @@ from src.md_to_py import md_table_to_lines BULLETS = False -CONTROLS_BEGIN_INDEX = 0 -CONTROLS_END_INDEX = 0 -DEFAULT_TODO = "" +CONTROLS_BEGIN_INDEX = 55 +CONTROLS_END_INDEX = 79 +DEFAULT_TODO = "todo.txt" ENUMERATE = False -FILENAME = Path() +FILENAME = Path(DEFAULT_TODO) HEADER = "" -HELP_FILE = Path() -INDENT = 0 +HELP_FILE = Path(__file__).parent.parent.joinpath("README.md").absolute() +INDENT = 2 NO_GUI = False RELATIVE_ENUMERATE = False SIMPLE_BOXES = False STRIKETHROUGH = False -def init( - bullets, - controls_begin_index, - controls_end_index, - default_todo, - this_enumerate, - filename, - header, - help_file, - indent, - no_gui, - relative_enumerate, - simple_boxes, - strikethrough, -): - global BULLETS - global CONTROLS_BEGIN_INDEX - global CONTROLS_END_INDEX - global DEFAULT_TODO - global ENUMERATE - global FILENAME - global HEADER - global HELP_FILE - global INDENT - global NO_GUI - global RELATIVE_ENUMERATE - global SIMPLE_BOXES - global STRIKETHROUGH - - BULLETS = bullets - CONTROLS_BEGIN_INDEX = controls_begin_index - CONTROLS_END_INDEX = controls_end_index - DEFAULT_TODO = default_todo - ENUMERATE = this_enumerate - FILENAME = filename - HEADER = header - HELP_FILE = help_file - INDENT = indent - NO_GUI = no_gui - RELATIVE_ENUMERATE = relative_enumerate - SIMPLE_BOXES = simple_boxes - STRIKETHROUGH = strikethrough - - def get_args() -> Namespace: parser = ArgumentParser( description="Ndo is a todo list program to help you manage your todo lists", @@ -172,3 +128,24 @@ def get_args() -> Namespace: Default is filename.", ) return parser.parse_args() + +command_line_args = get_args() +BULLETS = command_line_args.bullet_display +ENUMERATE = command_line_args.enumerate +FILENAME = ( + Path(command_line_args.filename, DEFAULT_TODO) + if Path(command_line_args.filename).is_dir() + else Path(command_line_args.filename) +) +HEADER = ( + FILENAME.as_posix() + if command_line_args.title == HEADER + else " ".join(command_line_args.title) +) +HELP_FILE = Path(command_line_args.help_file) +INDENT = command_line_args.indentation_level +NO_GUI = command_line_args.no_gui +RELATIVE_ENUMERATE = command_line_args.relative_enumeration +SIMPLE_BOXES = command_line_args.simple_boxes +STRIKETHROUGH = command_line_args.strikethrough +del command_line_args diff --git a/src/get_todo.py b/src/get_todo.py index e7c9369..2142821 100644 --- a/src/get_todo.py +++ b/src/get_todo.py @@ -6,13 +6,7 @@ from src.class_mode import Mode from src.class_todo import Todo - -INDENT = 0 - - -def init(indent): - global INDENT - INDENT = indent +from src.get_args import INDENT def set_header(stdscr: Any, message: str) -> None: diff --git a/src/print_todos.py b/src/print_todos.py index 50fcbb6..f1456f6 100644 --- a/src/print_todos.py +++ b/src/print_todos.py @@ -7,42 +7,17 @@ from src.class_todo import Todo from src.class_cursor import Cursor - -T = TypeVar("T") - -BULLETS = False -ENUMERATE = False -INDENT = 0 -NO_GUI = False -RELATIVE_ENUMERATE = False -SIMPLE_BOXES = False -STRIKETHROUGH = False +from src.get_args import ( + INDENT, + STRIKETHROUGH, + SIMPLE_BOXES, + BULLETS, + ENUMERATE, + RELATIVE_ENUMERATE, +) -def init( - bullets, - this_enumerate, - indent, - no_gui, - relative_enumerate, - simple_boxes, - should_strikethrough, -): - global BULLETS - global ENUMERATE - global INDENT - global NO_GUI - global RELATIVE_ENUMERATE - global SIMPLE_BOXES - global STRIKETHROUGH - - BULLETS = bullets - ENUMERATE = this_enumerate - INDENT = indent - NO_GUI = no_gui - RELATIVE_ENUMERATE = relative_enumerate - SIMPLE_BOXES = simple_boxes - STRIKETHROUGH = should_strikethrough +T = TypeVar("T") def get_bullet(indentation_level: int) -> str: diff --git a/todo.py b/todo.py index 6d6b44b..7bcc3fe 100755 --- a/todo.py +++ b/todo.py @@ -16,28 +16,17 @@ from src.class_history import UndoRedo from src.class_mode import Mode from src.class_todo import Todo -from src.class_todo import init as init_todo_class -from src.get_args import get_args -from src.get_args import init as init_get_args +from src.get_args import ( + CONTROLS_BEGIN_INDEX, + CONTROLS_END_INDEX, + FILENAME, + HEADER, + HELP_FILE, + NO_GUI, +) from src.get_todo import hline, set_header, wgetnstr -from src.get_todo import init as init_wgetnstr from src.md_to_py import md_table_to_lines -from src.print_todos import print_todos, make_printable_sublist -from src.print_todos import init as init_print_todos - -BULLETS = False -CONTROLS_BEGIN_INDEX = 55 -CONTROLS_END_INDEX = 79 -DEFAULT_TODO = "todo.txt" -ENUMERATE = False -FILENAME = Path(DEFAULT_TODO) -HEADER = "" -HELP_FILE = Path(__file__).parent.joinpath("README.md").absolute() -INDENT = 2 -NO_GUI = False -RELATIVE_ENUMERATE = False -SIMPLE_BOXES = False -STRIKETHROUGH = False +from src.print_todos import make_printable_sublist, print_todos PRINT_HISTORY = False HISTORY_FILE = "debugging/log.txt" @@ -712,8 +701,6 @@ def init() -> None: def main(stdscr: Any, header: str) -> int: init() - init_todo_class(INDENT) - init_wgetnstr(INDENT) todos = validate_file(read_file(FILENAME)) selected = Cursor(0) history = UndoRedo() @@ -860,50 +847,6 @@ def main(stdscr: Any, header: str) -> int: if __name__ == "__main__": - init_get_args( - BULLETS, - CONTROLS_BEGIN_INDEX, - CONTROLS_END_INDEX, - DEFAULT_TODO, - ENUMERATE, - FILENAME, - HEADER, - HELP_FILE, - INDENT, - NO_GUI, - RELATIVE_ENUMERATE, - SIMPLE_BOXES, - STRIKETHROUGH, - ) - command_line_args = get_args() - BULLETS = command_line_args.bullet_display - ENUMERATE = command_line_args.enumerate - FILENAME = ( - Path(command_line_args.filename, DEFAULT_TODO) - if Path(command_line_args.filename).is_dir() - else Path(command_line_args.filename) - ) - HEADER = ( - FILENAME.as_posix() - if command_line_args.title == HEADER - else " ".join(command_line_args.title) - ) - HELP_FILE = Path(command_line_args.help_file) - INDENT = command_line_args.indentation_level - NO_GUI = command_line_args.no_gui - RELATIVE_ENUMERATE = command_line_args.relative_enumeration - SIMPLE_BOXES = command_line_args.simple_boxes - STRIKETHROUGH = command_line_args.strikethrough - del command_line_args - init_print_todos( - BULLETS, - ENUMERATE, - INDENT, - NO_GUI, - RELATIVE_ENUMERATE, - SIMPLE_BOXES, - STRIKETHROUGH, - ) if NO_GUI: print(f"{HEADER}:") print_todos(None, validate_file(read_file(FILENAME)), Cursor(0))