Skip to content

Commit 968a003

Browse files
authored
Merge pull request #268 from ReadAlongs/dev.ej/cli-tweaks
Dev.ej/cli tweaks
2 parents 51c0cd2 + 42d792c commit 968a003

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

‎readalongs/cli.py‎

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
}
3535

3636
SUPPORTED_OUTPUT_FORMATS_DESC = ", ".join(
37-
k + f" ({v})" for k, v in SUPPORTED_OUTPUT_FORMATS.items()
37+
k + f" ({v})" for k, v in SUPPORTED_OUTPUT_FORMATS.items() if k != "html"
3838
)
3939

4040

@@ -122,6 +122,14 @@ def cli():
122122
"""
123123

124124

125+
LANGUAGES_DETAILS = (
126+
"use 'und' for the generic language-independent mapping; "
127+
"multiple codes can be joined by ',' or ':', or by repeating the option, "
128+
"to enable the g2p cascade (run 'readalongs g2p -h' for details); "
129+
"run 'readalongs langs' to list all supported languages."
130+
)
131+
132+
125133
@cli.command( # type: ignore # noqa: C901 # some versions of flake8 need this here
126134
context_settings=CONTEXT_SETTINGS, short_help="Force align a text and a sound file."
127135
)
@@ -147,8 +155,8 @@ def cli():
147155
callback=JoinerCallbackForClick(SUPPORTED_OUTPUT_FORMATS, drop_case=True),
148156
help=(
149157
"Comma- or colon-separated list of additional output file formats to export to. "
150-
"The text is always exported as XML and alignments as SMIL, but "
151-
"one or more of these formats can be requested in addition:\b \n\n"
158+
"The www bundle and Offline HTML are always generated, "
159+
"but one or more of these formats can be requested in addition:\b \n\n"
152160
+ SUPPORTED_OUTPUT_FORMATS_DESC
153161
),
154162
)
@@ -189,9 +197,7 @@ def cli():
189197
callback=JoinerCallbackForClick(get_langs_deferred()),
190198
help=(
191199
"The language code(s) for text in TEXTFILE (use only with plain text input); "
192-
"multiple codes can be joined by ',' or ':', or by repeating the option, "
193-
"to enable the g2p cascade (run 'readalongs g2p -h' for details); "
194-
"run 'readalongs langs' to list all supported languages."
200+
+ LANGUAGES_DETAILS
195201
),
196202
)
197203
@click.option(
@@ -365,7 +371,8 @@ def align(**kwargs): # noqa: C901 # some versions of flake8 need this here ins
365371
if not kwargs["language"]:
366372
raise click.BadParameter(
367373
"No input language specified for plain text input. "
368-
"Please provide the -l/--language switch."
374+
"Please provide the -l/--language switch.\n"
375+
"You can use '-l und' if you don't know the language or if it's not explicitly supported."
369376
)
370377
languages = list(kwargs["language"])
371378
if not kwargs["lang_no_append_und"] and "und" not in languages:
@@ -402,6 +409,9 @@ def align(**kwargs): # noqa: C901 # some versions of flake8 need this here ins
402409
# sys.exit(1)
403410

404411
output_formats = kwargs["output_formats"]
412+
# Now that Offline HTML is the editable format in Studio-Web, always generate it.
413+
if "html" not in output_formats:
414+
output_formats = [*output_formats, "html"]
405415

406416
save_readalong(
407417
align_results=results,
@@ -418,6 +428,7 @@ def align(**kwargs): # noqa: C901 # some versions of flake8 need this here ins
418428
context_settings=CONTEXT_SETTINGS,
419429
short_help="Renamed: use 'readalongs make-xml' instead.",
420430
deprecated=True,
431+
hidden=True,
421432
)
422433
@click.argument("plaintextfile", type=click.File("r", encoding="utf-8-sig", lazy=True))
423434
@click.argument("xmlfile", type=click.Path(), required=False, default="")
@@ -439,12 +450,7 @@ def align(**kwargs): # noqa: C901 # some versions of flake8 need this here ins
439450
required=True,
440451
multiple=True,
441452
callback=JoinerCallbackForClick(get_langs_deferred()),
442-
help=(
443-
"The language code(s) for text in PLAINTEXTFILE; "
444-
"multiple codes can be joined by ',' or ':', or by repeating the option, "
445-
"to enable the g2p cascade (run 'readalongs g2p -h' for details); "
446-
"run 'readalongs langs' to list all supported languages."
447-
),
453+
help=("The language code(s) for text in PLAINTEXTFILE; " + LANGUAGES_DETAILS),
448454
)
449455
def prepare(**kwargs):
450456
"""DEPRECATED - renamed: use `readalongs make-xml` instead.
@@ -491,12 +497,7 @@ def prepare(**kwargs):
491497
required=True,
492498
multiple=True,
493499
callback=JoinerCallbackForClick(get_langs_deferred()),
494-
help=(
495-
"The language code(s) for text in PLAINTEXTFILE; "
496-
"multiple codes can be joined by ',' or ':', or by repeating the option, "
497-
"to enable the g2p cascade (run 'readalongs g2p -h' for details); "
498-
"run 'readalongs langs' to list all supported languages."
499-
),
500+
help=("The language code(s) for text in PLAINTEXTFILE; " + LANGUAGES_DETAILS),
500501
)
501502
def make_xml(**kwargs):
502503
"""make XMLFILE for 'readalongs align' from PLAINTEXTFILE.

0 commit comments

Comments
 (0)