JustBash.CLI.Invocation (JustBash v0.4.0)

View Source

The single argument passed to a JustBash.CLI command handler.

A handler is a one-argument function that receives an %Invocation{} and returns {result, bash} — exactly the contract of JustBash.Commands.Command.execute/3.

def review(%JustBash.CLI.Invocation{flags: flags, bash: bash}) do
  report = MyApp.PullRequests.fetch!(flags.report, bash.context.user)
  {JustBash.Commands.Command.ok(render(report, flags.format)), bash}
end

Fields

  • :bash — the full JustBash.t/0 struct (fs, env, context, …)
  • :flags — a map of parsed flag values, keyed by the flag's atom name
  • :args — the remaining positional arguments, as a list of strings
  • :extra_flags — undeclared flag tokens collected when the leaf sets allow_unknown_flags: true, as a raw list of strings (empty otherwise); ready to forward verbatim to a backend
  • :stdin — the command's stdin, as a string
  • :path — the resolved subcommand path that routed here, e.g. ["pr", "review"]

Summary

Types

t()

@type t() :: %JustBash.CLI.Invocation{
  args: [String.t()],
  bash: JustBash.t(),
  extra_flags: [String.t()],
  flags: %{optional(atom()) => term()},
  path: [String.t()],
  stdin: String.t()
}