Yeesh.Executor (Yeesh v0.8.3)

View Source

Parses and executes commands.

Tokenizes input into command name + arguments (respecting quoting), looks up the command in the registry, and executes it.

Execution is synchronous in the current release. Async streaming execution is planned for Milestone 3.

OS command passthrough is planned for Milestone 2.

Summary

Functions

Executes a command line in the context of the given session.

Tokenizes a command line into a list of strings, respecting single and double quoting.

Functions

execute(input, session_pid)

@spec execute(String.t(), pid()) :: {String.t(), Yeesh.Session.t()}

Executes a command line in the context of the given session.

Returns {output, updated_session_state}.

tokenize(input)

@spec tokenize(String.t()) :: {:ok, [String.t()]} | {:error, String.t()}

Tokenizes a command line into a list of strings, respecting single and double quoting.

Examples

iex> Yeesh.Executor.tokenize(~s|echo "hello world"|)
{:ok, ["echo", "hello world"]}

iex> Yeesh.Executor.tokenize(~s|echo 'it\'s fine'|)
{:ok, ["echo", "it's fine"]}