nat.cli.main#

Functions#

run_cli(→ int | None)

Process entrypoint for the nat console script.

Module Contents#

run_cli() int | None#

Process entrypoint for the nat console script.

Bootstraps sys.path so the nat package can be imported from a source checkout, then delegates to the Click cli group with standalone_mode=False so the wrapper sees real exceptions (KeyboardInterrupt, click.Abort, click.ClickException) rather than the generic SystemExit that standalone mode produces. Each branch records a single nat_cli_command telemetry event via nat.cli.telemetry_hook.emit_command_event() before re-raising or calling sys.exit().

Side effects:
  • Sets TRANSFORMERS_VERBOSITY=error in the process environment.

  • Appends the packages/.../src parent directory to sys.path.

  • Replicates Click’s standalone-mode user-facing UX: prints the "Aborted!" line on Ctrl-C / click.Abort; calls ClickException.show() on usage errors.

  • Emits exactly one telemetry event per invocation (success, failure, or interrupted), gated by the user’s persisted consent decision and the NAT_TELEMETRY_ENABLED env var.

Returns:

On the success path, the integer exit code if the invoked Click callback returned an int (Click’s convention for “exit with this code” without raising); otherwise None (treated as exit 0 by the console-script wrapper’s sys.exit(...)). On every non-success path, the function does not return — SystemExit is re-raised after telemetry emission so the host process exits with the appropriate status code.

Raises:
SystemExit: Re-raised after a telemetry event is emitted, so the

host process exits with the appropriate status code (0 on success / --help, 1 on uncaught exception or click.Abort, 2 on click.UsageError, 130 on KeyboardInterrupt, exc.exit_code for other click.ClickException subclasses).