AshOps.Task.ArgSchema (ash_ops v0.2.3)

A struct which contains information about the arguments a task expects to receive.

Summary

Functions

Append a positional argument to the end of the argument list

Return the default arguments that all tasks expect to take.

Parse and validate the command-line arguments.

Prepend a positional argument to the beginning argument list

Remove a positional argument by name.

Remove a switch from the argument schemas

Display usage information about the arguments

Types

t()

@type t() :: %AshOps.Task.ArgSchema{
  op_schema: OptionParser.options(),
  so_schema: Spark.Options.schema()
}

Functions

add_switch(arg_schema, name, op_type, so_schema, aliases \\ [])

@spec add_switch(t(), atom(), atom(), keyword(), [atom()]) :: t()

Add a switch to the arguments

Arguments

  • name the name of the switch - this will be dasherised by OptionParser.
  • op_type the type to cast the argument to (as per OptionParser.parse/2).
  • so_schema the Spark.Options schema fragment for to validate the resulting input.
  • help_text the text to display when asked to render usage information.
  • aliases a list of "short name" aliases for the switch.

append_positional(arg_schema, name, help_text)

@spec append_positional(t(), atom(), String.t()) :: t()

Append a positional argument to the end of the argument list

ie after any action arguments taken by the task.

default(task)

@spec default(AshOps.entity()) :: t()

Return the default arguments that all tasks expect to take.

parse(arg_schema, argv)

@spec parse(t(), OptionParser.argv()) ::
  {:ok, %{required(atom()) => any()}} | {:error, any()}

Parse and validate the command-line arguments.

prepend_positional(arg_schema, name, help_text)

@spec prepend_positional(t(), atom(), String.t()) :: t()

Prepend a positional argument to the beginning argument list

ie before any action arguments taken by the task.

remove_positional(arg_schema, name)

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

Remove a positional argument by name.

remove_switch(arg_schema, name)

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

Remove a switch from the argument schemas

usage(task, arg_schema)

@spec usage(AshOps.entity(), t()) :: String.t()

Display usage information about the arguments