PtcRunner.Kernel.CommandRejection (PtcRunner v0.14.0)

Copy Markdown View Source

Closed phase-1 parser rejection.

Unknown switches are deliberately not retained. The value may carry only a declaration-owned accepted list. Missing-value, destination, and collision failures retain only declaration-owned switch names, never caller-owned paths.

Summary

Types

t()

@type t() :: %PtcRunner.Kernel.CommandRejection{
  accepted: [binary()],
  code: atom(),
  command: atom(),
  conflicts: [binary()],
  destination: binary() | nil,
  kind:
    :generic
    | :unknown_switch
    | :missing_switch_value
    | :positional_arity
    | :invalid_destination
    | :unknown_page
    | :unknown_example
    | :destination_exists
    | :destination_collision
    | :private_output_recovery_collision
    | :init_destination_collision
    | :project_host_undeclared,
  option: binary() | nil
}

Functions

destination_collision(command, first, second, frontend)

docs_page_unknown()

@spec docs_page_unknown() :: t()

Builds the rejection for a ptc docs page name nothing serves.

Bare ptc docs already lists the served set, so the failing form is the one case where a reader is holding a name and cannot see the alternatives. The list is declaration-owned, like the accepted switches of unknown_switch/2; the caller's own token is not retained.

envelope_destination_exists(command, frontend)

Builds the rejection for an envelope destination that already exists.

The reserve behind every published artifact refuses to clobber, so an existing envelope path is a failure however late it is discovered. Discovering it at admission is the difference between refusing a command and refusing it after the workflow has executed and been billed. The caller's path is not retained; the switch name is declaration-owned.

example_unknown()

@spec example_unknown() :: t()

Builds the rejection for a ptc init --example name nothing embeds.

Same shape as docs_page_unknown/0: the embedded set is declaration-owned and is listed, while the caller's own token is not retained.

generic(command, code)

@spec generic(atom(), atom()) :: t()

init_destination_collision(frontend)

@spec init_destination_collision(PtcRunner.Kernel.CommandDeclaration.frontend()) ::
  t()

invalid_destination(command, destination, frontend)

missing_switch_value(command, switch, frontend)

positional_arity(command)

@spec positional_arity(PtcRunner.Kernel.CommandDeclaration.command()) :: t()

private_output_recovery_collision(frontend)

@spec private_output_recovery_collision(
  PtcRunner.Kernel.CommandDeclaration.frontend()
) :: t()

undeclared_project_host(command)

@spec undeclared_project_host(:models | :doctor) :: t()

Builds the rejection for a project document that declares no host.

Restricted to the two commands that need one, so generic/2 cannot mint a command/code pair the envelope contract refuses and CommandOutcome would raise on.

unknown_switch(command, frontend)

@spec unknown_switch(atom(), PtcRunner.Kernel.CommandDeclaration.frontend()) :: t()