CLIs: allow -h and show defaults uniformly, harmonise help, drop

remaining redundant negative options
This commit is contained in:
Robert Sachunsky 2026-05-12 18:34:56 +02:00
parent cd62f13872
commit 7ed1a1ebac
5 changed files with 42 additions and 23 deletions

View file

@ -1,6 +1,8 @@
import click import click
@click.command() @click.command(context_settings=dict(
help_option_names=['-h', '--help'],
show_default=True))
@click.option( @click.option(
'--patches/--no-patches', '--patches/--no-patches',
default=True, default=True,

View file

@ -1,6 +1,8 @@
import click import click
@click.command() @click.command(context_settings=dict(
help_option_names=['-h', '--help'],
show_default=True))
@click.option( @click.option(
"--image", "--image",
"-i", "-i",

View file

@ -1,6 +1,8 @@
import click import click
@click.command() @click.command(context_settings=dict(
help_option_names=['-h', '--help'],
show_default=True))
@click.option( @click.option(
"--image", "--image",
"-i", "-i",
@ -30,36 +32,40 @@ import click
@click.option( @click.option(
"--save_images", "--save_images",
"-si", "-si",
help="if a directory is given, images in documents will be cropped and saved there", help="if a directory is given, cropped images of pages will be saved there",
type=click.Path(exists=True, file_okay=False), type=click.Path(exists=True, file_okay=False),
) )
@click.option( @click.option(
"--enable-plotting/--disable-plotting", "--enable-plotting",
"-ep/-noep", "-ep",
is_flag=True, is_flag=True,
help="If set, will plot intermediary files and images", help="plot intermediary diagnostic images to files",
) )
@click.option( @click.option(
"--input_binary/--input-RGB", "--input_binary",
"-ib/-irgb", "-ib",
is_flag=True, is_flag=True,
help="In general, eynollah uses RGB as input but if the input document is very dark, very bright or for any other reason you can turn on input binarization. When this flag is set, eynollah will binarize the RGB input document, you should always provide RGB images to eynollah.", help="In general, eynollah uses RGB as input, but if the input document is very dark, very bright or for any other reason you can turn on internal binarization here. When set, eynollah will binarize the RGB input document first.",
) )
@click.option( @click.option(
"--ignore_page_extraction/--extract_page_included", "--ignore_page_extraction",
"-ipe/-epi", "-ipe",
is_flag=True, is_flag=True,
help="if this parameter set to true, this tool would ignore page extraction", help="ignore page extraction (cropping via page frame detection model)",
) )
@click.option( @click.option(
"--num_col_upper", "--num_col_upper",
"-ncu", "-ncu",
help="lower limit of columns in document image", default=0,
type=click.IntRange(min=0),
help="lower limit of columns in document image; 0 means autodetected from model",
) )
@click.option( @click.option(
"--num_col_lower", "--num_col_lower",
"-ncl", "-ncl",
help="upper limit of columns in document image", default=0,
type=click.IntRange(min=0),
help="upper limit of columns in document image; 0 means autodetected from model",
) )
@click.pass_context @click.pass_context
def extract_images_cli( def extract_images_cli(

View file

@ -1,6 +1,8 @@
import click import click
@click.command() @click.command(context_settings=dict(
help_option_names=['-h', '--help'],
show_default=True))
@click.option( @click.option(
"--image", "--image",
"-i", "-i",
@ -16,7 +18,7 @@ import click
@click.option( @click.option(
"--dir_in_bin", "--dir_in_bin",
"-dib", "-dib",
help=("directory of binarized images (in addition to --dir_in for RGB images; filename stems must match the RGB image files, with '.png' \n Perform prediction using both RGB and binary images. (This does not necessarily improve results, however it may be beneficial for certain document images."), help=("directory of binarized images (in addition to --dir_in for RGB images; filename stems must match the RGB image files, with '.png'. \n Perform prediction using both RGB and binary images. (This may improve results for certain document images.)"),
type=click.Path(exists=True, file_okay=False), type=click.Path(exists=True, file_okay=False),
) )
@click.option( @click.option(
@ -47,25 +49,30 @@ import click
) )
@click.option( @click.option(
"--tr_ocr", "--tr_ocr",
"-trocr/-notrocr", "-trocr",
is_flag=True, is_flag=True,
help="if this parameter set to true, transformer ocr will be applied, otherwise cnn_rnn model.", help="use transformer OCR (instead of classic CNN-RNN) model",
) )
@click.option( @click.option(
"--do_not_mask_with_textline_contour", "--do_not_mask_with_textline_contour",
"-nmtc/-mtc", "-nmtc",
is_flag=True, is_flag=True,
help="if this parameter set to true, cropped textline images will not be masked with textline contour.", help="skip masking each cropped textline image with its corresponding textline contour",
) )
@click.option( @click.option(
"--batch_size", "--batch_size",
"-bs", "-bs",
default=0,
type=click.IntRange(min=0),
help="number of inference batch size. Default b_s for trocr and cnn_rnn models are 2 and 8 respectively", help="number of inference batch size. Default b_s for trocr and cnn_rnn models are 2 and 8 respectively",
) )
@click.option( @click.option(
"--min_conf_value_of_textline_text", "--min_conf_value_of_textline_text",
"-min_conf", "-min_conf",
help="minimum OCR confidence value. Text lines with a confidence value lower than this threshold will not be included in the output XML file.", default=0.3,
type=click.FloatRange(min=0.0, max=1.0),
help="minimum OCR confidence threshold. Text lines with a lower confidence value will not be included in the output XML file.",
)
@click.option( @click.option(
"--device", "--device",
"-D", "-D",

View file

@ -1,6 +1,8 @@
import click import click
@click.command() @click.command(context_settings=dict(
help_option_names=['-h', '--help'],
show_default=True))
@click.option( @click.option(
"--input", "--input",
"-i", "-i",