runlet v1.0.0 Runlet.CLI

Compile runlet expresions

Link to this section Summary

Functions

Add a runlet expression to the end of a pipeline.

Compile a runlet expression into Elixr AST

Compile a runlet expression into the AST

Compile a runlet expression into the AST

Compile a runlet expression into Elixr AST

Insert a runlet pipeline into another pipeline.

Parse a runlet expression.

Add a runlet expression at the start of a pipeline.

Link to this section Types

Link to this type

e()

e() :: String.t() | [t()]
Link to this type

t()

t() :: {[atom()], atom()} | {{[atom()], atom()}, [String.t() | integer()]}

Link to this section Functions

Link to this function

aliases()

aliases() :: [t()]
Link to this function

append(code, command)

append(e(), e()) :: {:ok, [t()]} | {:error, String.t()}

Add a runlet expression to the end of a pipeline.

Examples

iex> Runlet.CLI.append(~s(test "foo" | bar 123 | another), ~s(insert | here)) {:ok, [{"test", ["foo"]}, {"bar", '{'}, {"another", []}, {"insert", []},

{"here", []}]}
Link to this function

ast(pipeline, commands)

Link to this function

compile(pipeline)

compile(e()) :: {:ok, [t()]} | {:error, String.t()}

Compile a runlet expression into Elixr AST

Commands are looked up in the application environment:

Application.get_env(:runlet, :aliases, [])

Link to this function

compile(pipeline, commands)

compile(e(), [t()]) :: {:ok, [t()]} | {:error, String.t()}

Compile a runlet expression into the AST

Examples

iex> Runlet.CLI.compile( ...> ~s(test "foo" | bar 123), ...> [{"test", [{[:Fake, :Cmd, :AddArg], :exec}, ...> {{:Fake, :Cmd, :StaticArg}, ["static arg"]}]}, ...> {"bar", {[:Fake, :Cmd, :IntArg], :exec}}]) {:ok, {:|>, [context: Elixir, import: Kernel],

[{:|>, [context: Elixir, import: Kernel],
  [{{:., [], [{:__aliases__, [alias: false], [:Fake, :Cmd, :AddArg]}, :exec]},
    [], ["foo"]},
   {{:., [],
     [{:__aliases__, [alias: false], {:Fake, :Cmd, :StaticArg}},
      ["static arg"]]}, [], ["foo"]}]},
 {{:., [], [{:__aliases__, [alias: false], [:Fake, :Cmd, :IntArg]}, :exec]},
  [], '{'}]}}
Link to this function

compile!(pipeline)

compile!(e()) :: [t()]

Compile a runlet expression into the AST

Commands are looked up in the application environment:

Application.get_env(:runlet, :aliases, [])

Link to this function

compile!(pipeline, commands)

compile!(e(), [t()]) :: [t()]

Compile a runlet expression into Elixr AST

Examples

iex> Runlet.CLI.compile!( ...> ~s(test "foo" | bar 123), ...> [{"test", [{[:Fake, :Cmd, :AddArg], :exec}, ...> {{:Fake, :Cmd, :StaticArg}, ["static arg"]}]}, ...> {"bar", {[:Fake, :Cmd, :IntArg], :exec}}]) {:|>, [context: Elixir, import: Kernel], [{:|>, [context: Elixir, import: Kernel],

 [{{:., [], [{:__aliases__, [alias: false], [:Fake, :Cmd, :AddArg]}, :exec]},
   [], ["foo"]},
  {{:., [],
    [{:__aliases__, [alias: false], {:Fake, :Cmd, :StaticArg}},
     ["static arg"]]}, [], ["foo"]}]},
{{:., [], [{:__aliases__, [alias: false], [:Fake, :Cmd, :IntArg]}, :exec]},
 [], '{'}]}
Link to this function

exec(ast, bind)

Link to this function

exec!(ast, bind)

Link to this function

expand(pipeline, fun)

expand([t()], (... -> any())) :: {:ok, [t()]} | {:error, String.t()}
Link to this function

insert(pipeline, command, position)

insert(e(), String.t() | [t()], integer()) ::
  {:ok, [t()]} | {:error, String.t()}

Insert a runlet pipeline into another pipeline.

Examples

iex> Runlet.CLI.insert(~s(test "foo" | bar 123 | another), ...> ~s(insert | here), 2) {:ok, [{"test", ["foo"]}, {"bar", '{'}, {"insert", []}, {"here", []},

{"another", []}]}
Link to this function

parse(command)

parse(e()) ::
  {:ok, [{String.t(), [integer() | float() | String.t()]}]}
  | {:error, String.t()}

Parse a runlet expression.

Examples

iex(7)> Runlet.CLI.parse(~s(test "foo" | bar 123 | out > 456)) {:ok, [{"test", ["foo"]}, {"bar", '{'}, {"out", []}, {">", [456]}]}

Link to this function

prepend(code, command)

prepend(e(), e()) :: {:ok, [t()]} | {:error, String.t()}

Add a runlet expression at the start of a pipeline.

Examples

iex> Runlet.CLI.prepend(~s(test "foo" | bar 123 | another), ~s(insert | here)) {:ok, [{"insert", []}, {"here", []}, {"test", ["foo"]}, {"bar", '{'},

{"another", []}]}
Link to this function

substitute(cmds, fun)

substitute([t()], (... -> any())) :: {:ok, [t()]} | {:error, String.t()}
Link to this function

substitute(list, fun, acc)