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

Copy Markdown

What every command runs with: the directories, the environment, the deployment's org, the terminal it writes to, the name it was typed as, and whether it prints JSON.

Summary

Functions

Returns the ID name names: name itself if it holds an org, or else name under the deployment's org.

Runs the operation id on the daemon. Returns its answer, or the reason it failed.

Returns an operation's answer, with its error as a message.

Returns the client that reaches the daemon: from WARDRIK_URL and WARDRIK_TOKEN if both are set, or from cli_token.

Writes said once a change is done, or the answer as JSON if the command was given --json.

Returns the context for env, the environment. The org is config.yaml's org, or default.

Returns the owner flags name: --org, or --user in the deployment's org, or else default.

Puts value in map under key, unless it's nil.

Writes data to the command's terminal.

Writes answer as JSON if the command was given --json. Otherwise calls shown with it.

Types

t()

@type t() :: %WardrikDaemon.CLI.Context{
  dirs: WardrikDaemon.Dirs.t(),
  env: %{required(String.t()) => String.t()},
  json?: boolean(),
  org: String.t(),
  program: String.t(),
  terminal: WardrikDaemon.CLI.Terminal.t()
}

Functions

agent(cx, name)

@spec agent(t(), String.t()) :: String.t()

Returns the ID name names: name itself if it holds an org, or else name under the deployment's org.

call(cx, id, input)

@spec call(t(), String.t(), map()) :: {:ok, map() | nil} | {:error, String.t()}

Runs the operation id on the daemon. Returns its answer, or the reason it failed.

called(arg)

@spec called({:ok, term()} | WardrikDaemon.Client.error()) ::
  {:ok, term()} | {:error, String.t()}

Returns an operation's answer, with its error as a message.

client(cx)

@spec client(t()) :: {:ok, WardrikDaemon.Client.t()} | {:error, String.t()}

Returns the client that reaches the daemon: from WARDRIK_URL and WARDRIK_TOKEN if both are set, or from cli_token.

done(cx, answer, said)

@spec done(t(), term(), Owl.Data.t()) :: :ok

Writes said once a change is done, or the answer as JSON if the command was given --json.

new(env)

@spec new(%{required(String.t()) => String.t()}) :: t()

Returns the context for env, the environment. The org is config.yaml's org, or default.

owner(cx, flags, default \\ "deployment")

@spec owner(t(), map(), String.t()) :: String.t()

Returns the owner flags name: --org, or --user in the deployment's org, or else default.

put(map, key, value)

@spec put(map(), String.t(), term()) :: map()

Puts value in map under key, unless it's nil.

puts(cx, data)

@spec puts(t(), Owl.Data.t()) :: :ok

Writes data to the command's terminal.

show(arg1, answer, shown)

@spec show(t(), term(), (term() -> term())) :: :ok

Writes answer as JSON if the command was given --json. Otherwise calls shown with it.