WardrikDaemon.CLI.Command (wardrik_daemon v0.1.0-rc.1)

Copy Markdown

One command wardrik takes, defined once for its help, its options and running it.

%WardrikDaemon.CLI.Command{
  name: "agent ls",
  shortcut: "ls",
  group: "Agents",
  arguments: "[QUERY]",
  switches: [all: :boolean],
  count: {0, :any},
  summary: "list the agents, and what each is doing",
  run: &ls/3
}

Fields

  • :name - required. The words that name it, as agent ls.
  • :group - required. The group help lists it under.
  • :summary - required. One line on what it does.
  • :arguments - how its arguments are typed in help, as AGENT MESSAGE.
  • :details - more lines for its own help.
  • :switches - the options it takes, as OptionParser takes them.
  • :count - how many arguments it takes: a number, or {least, :any}. 0 unless set.
  • :shortcut - a shorter name it also takes, as ls.
  • :run - takes the arguments, the switches and the WardrikDaemon.CLI.Context. nil for a command bin/wardrik runs itself.

Summary

Functions

Returns whether command takes count arguments.

Returns how command is typed, as agent show AGENT [--json].

Returns the words that name command.

Types

run()

@type run() :: ([String.t()], map(), WardrikDaemon.CLI.Context.t() ->
            :ok | {:error, String.t()})

t()

@type t() :: %WardrikDaemon.CLI.Command{
  arguments: String.t(),
  count: non_neg_integer() | {non_neg_integer(), :any},
  details: [String.t()],
  group: String.t(),
  name: String.t(),
  run: run() | nil,
  shortcut: String.t() | nil,
  summary: String.t(),
  switches: keyword()
}

Functions

takes?(command, count)

@spec takes?(t(), non_neg_integer()) :: boolean()

Returns whether command takes count arguments.

usage(command)

@spec usage(t()) :: String.t()

Returns how command is typed, as agent show AGENT [--json].

words(command)

@spec words(t()) :: [String.t()]

Returns the words that name command.