Skip to content

Commit 8276386

Browse files
committed
update main loops so command line utilities can be debugged from the command line
1 parent 969e408 commit 8276386

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

pdftocgen/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def main():
9090
print(usage_s, file=sys.stderr)
9191
sys.exit(2)
9292

93-
recipe_file: TextIO = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='ignore')
93+
recipe_file: TextIO = None
9494
readable: bool = False
9595
vpos: bool = False
9696
out: TextIO = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='ignore')
@@ -129,6 +129,8 @@ def main():
129129
print(usage_s, file=sys.stderr)
130130
sys.exit(1)
131131

132+
if not recipe_file:
133+
recipe_file = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='ignore')
132134
path_in: str = args[0]
133135
# done parsing arguments
134136

pdftocio/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def main():
9494
print(usage_s, file=sys.stderr)
9595
sys.exit(2)
9696

97-
toc_file: TextIO = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='ignore')
97+
toc_file: TextIO = None
9898
print_toc: bool = False
9999
readable: bool = False
100100
out: Optional[str] = None
@@ -131,6 +131,8 @@ def main():
131131
print(usage_s, file=sys.stderr)
132132
sys.exit(1)
133133

134+
if not toc_file:
135+
toc_file = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8', errors='ignore')
134136
path_in: str = args[0]
135137
# done parsing arguments
136138

0 commit comments

Comments
 (0)