ClientUtils.Harness.Onboarding.IO behaviour (client_utils v0.1.25)

View Source

How onboarding reaches a working copy.

Four operations, all rooted at the copy's directory, so the code that decides what a working copy needs never learns how the host stores it. ClientUtils.Harness.Onboarding.FileIO is the default and is what a generated application uses; CodeMySpec passes an adapter over its own Environments so the same onboarding runs against an in-memory copy in a spec.

Paths are always relative to the root and always use forward slashes.

Summary

Callbacks

Run command with args in root, returning {output, exit_status}.

Whether path exists under root.

Contents of path under root, or an error when it is not there.

Write contents to path under root, creating parents.

Callbacks

cmd(root, command, args)

@callback cmd(root :: String.t(), command :: String.t(), args :: [String.t()]) ::
  {String.t(), non_neg_integer()}

Run command with args in root, returning {output, exit_status}.

Never raises — a missing binary is {message, non-zero}. Onboarding treats a step that could not run the same as one that refused, and neither aborts the command.

exists?(root, path)

@callback exists?(root :: String.t(), path :: String.t()) :: boolean()

Whether path exists under root.

read(root, path)

@callback read(root :: String.t(), path :: String.t()) ::
  {:ok, String.t()} | {:error, term()}

Contents of path under root, or an error when it is not there.

write(root, path, contents)

@callback write(root :: String.t(), path :: String.t(), contents :: String.t()) ::
  :ok | {:error, term()}

Write contents to path under root, creating parents.