Skip to content

Main Application API

hatchling.app

Classes

Functions

main()

Entry point function that runs the async main function.

Returns:

Name Type Description
int

Exit code from the async main function.

Source code in hatchling/app.py
55
56
57
58
59
60
61
def main():
    """Entry point function that runs the async main function.

    Returns:
        int: Exit code from the async main function.
    """
    return asyncio.run(main_async())

main_async() async

Main entry point for the application.

Returns:

Name Type Description
int

Exit code - 0 for successful execution.

Raises:

Type Description
Exception

Any unhandled exceptions that occur during execution.

Source code in hatchling/app.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
async def main_async():
    """Main entry point for the application.

    Returns:
        int: Exit code - 0 for successful execution.

    Raises:
        Exception: Any unhandled exceptions that occur during execution.
    """
    settings_registry = None
    try:

        settings_registry = SettingsRegistry()

        # Initialize translation loader
        init_translation_loader(languages_dir=settings_registry.settings.paths.hatchling_source_dir / "hatchling" / "config" / "languages",
                                 default_language_code=settings_registry.settings.ui.language_code)

        # Create and run CLI chat interface
        cli_chat = CLIChat(settings_registry)

        await cli_chat.initialize_and_run()

        return 0

    except KeyboardInterrupt:
        log.info("Application interrupted by user")
    except Exception as e:
        log.error(f"Error in main application: {e}")
    finally:
        try:
            settings_registry.save_persistent_settings()
            log.info("Persistent settings saved on exit")
        except Exception as e:
            log.error(f"Failed to save persistent settings on exit: {e}")

This module contains the main entry point for the Hatchling application.