Skip to content

Commit

Permalink
Enhance argument parser
Browse files Browse the repository at this point in the history
  • Loading branch information
AliOsm committed Jul 19, 2024
1 parent a10a75c commit d0ca025
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tahweel/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def prepare_package_dirs() -> None:


def process_file(args: TahweelArgumentParser, processor: GoogleDriveOcrProcessor, file_manager: PdfFileManager) -> None:
if args.skip_output_check and file_manager.already_processed(args.tahweel_type, args.file_or_dir_path):
if not args.skip_output_check and file_manager.already_processed(args.tahweel_type, args.file_or_dir_path):
return

file_manager.to_images()
Expand Down
13 changes: 9 additions & 4 deletions tahweel/tahweel_argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ class TahweelArgumentParser(Tap):
"""Use this flag in development only to skip the output check."""

tahweel_type: TahweelType = TahweelType.FILE
"""Don't use this argument, it will be auto-set based on file_or_dir_path."""
"""Don't use this argument, it will be auto-set based on `file_or_dir_path`."""

def configure(self):
self.add_argument('file_or_dir_path', type=Path, help='Path to the file or directory to be processed')

self.add_argument('--version', action='version', version=importlib.metadata.version('tahweel'))
self.add_argument('file_or_dir_path', type=Path, help='Path to the file or directory to be processed.')

self.add_argument(
'--version',
action='version',
version=importlib.metadata.version('tahweel'),
help="show program's version number and exit",
)

def process_args(self):
self.tahweel_type = TahweelType.FILE if self.file_or_dir_path.is_file() else TahweelType.DIR

0 comments on commit d0ca025

Please sign in to comment.