v4.10.0
Features
-
New
App.error_formatterfield to control outCycloptsErrorare displayed. The formatter receives aCycloptsErrorand returns anyrich-printable object, replacing the defaultCycloptsPanel. Can be set at app creation or passed as a runtime override toparse_args/__call__/run_async. by @BrianPugh in #771By default (without
error_formatter), errors are displayed in a Rich panel:$ my-app foo ╭─ Error ─────────────────────────────────────────────────╮ │ Invalid value "foo" for "VALUE": unable to convert │ │ "foo" into int. │ ╰─────────────────────────────────────────────────────────╯With a custom formatter, you can simplify or restyle the output:
from cyclopts import App, CycloptsError def my_error_formatter(e: CycloptsError): return f"[bold red]error:[/bold red] {e}" app = App(error_formatter=my_error_formatter) @app.default def main(value: int): pass app()
$ my-app foo error: Invalid value "foo" for "VALUE": unable to convert "foo" into int.
Full Changelog: v4.9.0...v4.10.0