View Source Runlet.CLI (runlet v1.2.5)
Compile runlet expressions
Summary
Functions
Add a runlet expression to the end of a pipeline.
Compile a runlet expression to AST
Compile a runlet expression to AST
Compile a runlet expression to AST.
Compile a runlet expression to AST.
Insert a runlet pipeline into another pipeline.
Tokenize a runlet expression.
Parse a runlet expression.
Add a runlet expression at the start of a pipeline.
Types
Functions
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", []}]}
Compile a runlet expression to AST
Commands are looked up in the application environment:
Application.get_env(:runlet, :aliases, [])
Compile a runlet expression to 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]},
[], '{'}]}}
Compile a runlet expression to AST.
Commands are looked up in the application environment:
Application.get_env(:runlet, :aliases, [])
Compile a runlet expression to 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]},
[], '{'}]}
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", []}]}
Tokenize a runlet expression.
Examples
iex> Runlet.CLI.lex(~s(test "foo" | bar 123 | out > 456))
{:ok,
[
{:command, 1, "test"},
{:string, 1, 'foo'},
{:|, 1},
{:command, 1, "bar"},
{:integer, 1, 123},
{:|, 1},
{:command, 1, "out"},
{:>, 1},
{:integer, 1, 456}
], 1}
@spec parse(e()) :: {:ok, [{String.t(), [Runlet.PID.t() | String.t()]}]} | {:error, String.t()}
Parse a runlet expression.
Examples
iex> Runlet.CLI.parse(~s(test "foo" | bar 123 | out > 456))
{:ok, [{"test", ["foo"]}, {"bar", '{'}, {"out", []}, {">", [456]}]}
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", []}]}