From d0ca0252b035758dddb1abe3a5fe686c264f95ca Mon Sep 17 00:00:00 2001 From: Ali Hamdi Ali Fadel Date: Fri, 19 Jul 2024 17:45:51 +0000 Subject: [PATCH] Enhance argument parser --- tahweel/cli.py | 2 +- tahweel/tahweel_argument_parser.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tahweel/cli.py b/tahweel/cli.py index ab46dde..8ecfa19 100644 --- a/tahweel/cli.py +++ b/tahweel/cli.py @@ -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() diff --git a/tahweel/tahweel_argument_parser.py b/tahweel/tahweel_argument_parser.py index ed8b8fe..cb0235f 100644 --- a/tahweel/tahweel_argument_parser.py +++ b/tahweel/tahweel_argument_parser.py @@ -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