Skip to content

Commit

Permalink
1.1.2: update deps, fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
msantos committed Nov 29, 2021
1 parent 147dbe1 commit cc15b78
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 34 deletions.
3 changes: 2 additions & 1 deletion lib/runlet.ex
Expand Up @@ -15,6 +15,7 @@ defmodule Runlet do
pipeline: binary,
stdout: (String.t() -> (Runlet.Event.t() | String.t() -> any)) | nil,
aliases: Runlet.CLI.t() | nil,
append: binary | Runlet.CLI.t(),
state: any
}

Expand Down Expand Up @@ -102,7 +103,7 @@ defmodule Runlet do
end
end

@spec append(%Runlet{append: binary | Runlet.CLI.t()}, [Runlet.CLI.t()]) ::
@spec append(Runlet.t(), [Runlet.CLI.t()]) ::
{:ok, [Runlet.CLI.t()]} | {:error, String.t()}
defp append(%Runlet{append: nil}, pipeline) do
{:ok, pipeline}
Expand Down
25 changes: 10 additions & 15 deletions lib/runlet/cli.ex
Expand Up @@ -99,6 +99,11 @@ defmodule Runlet.CLI do

def ast(pipeline, commands) do
fun = fn {cmd, arg} ->
maybe_argv = fn
{{_mod, _fun}, _argv} = t -> t
{mod, fun} -> {{mod, fun}, arg}
end

case List.keyfind(commands, cmd, 0) do
nil ->
{:error, "#{cmd}: not found"}
Expand All @@ -110,21 +115,12 @@ defmodule Runlet.CLI do
{:ok, [{{mod, fun}, arg}]}

{^cmd, form} when is_list(form) ->
insn =
form
|> Enum.map(fn
{{_mod, _fun}, _argv} = t -> t
{mod, fun} -> {{mod, fun}, arg}
end)
|> Enum.reverse()

{:ok, insn}
{:ok, form |> Enum.map(maybe_argv) |> Enum.reverse()}
end
end

with {:ok, command} <- parse(pipeline),
{:ok, code} <- expand(command, fun) do
{:ok, code}
with {:ok, command} <- parse(pipeline) do
expand(command, fun)
end
end

Expand Down Expand Up @@ -181,9 +177,8 @@ defmodule Runlet.CLI do
| {:error, String.t()}
def parse(command) when is_binary(command) do
result =
with {:ok, tokens, _} <- lex(command),
{:ok, pipeline} <- :runlet_parser.parse(tokens) do
{:ok, pipeline}
with {:ok, tokens, _} <- lex(command) do
:runlet_parser.parse(tokens)
end

case result do
Expand Down
17 changes: 5 additions & 12 deletions lib/runlet/cmd/fmt.ex
Expand Up @@ -18,17 +18,11 @@ defmodule Runlet.Cmd.Fmt do
end

e =
case f do
true ->
case t do
%Runlet.Event{} ->
Runlet.Fmt.fmt(t.event)
case {f, t} do
{true, %Runlet.Event{}} ->
Runlet.Fmt.fmt(t.event)

_ ->
Runlet.Fmt.fmt(t)
end

false ->
_ ->
Runlet.Fmt.fmt(t)
end
|> URI.encode(&(&1 == 9 || &1 == 10 || (&1 >= 32 && &1 <= 126)))
Expand All @@ -39,8 +33,7 @@ defmodule Runlet.Cmd.Fmt do
"#{e}",
t.attr
|> Map.to_list()
|> Enum.map(fn {_, v} -> Runlet.Fmt.fmt(v) end)
|> Enum.join(" "),
|> Enum.map_join(" ", fn {_, v} -> Runlet.Fmt.fmt(v) end),
"#{Runlet.Fmt.fmt(self())}"
],
" "
Expand Down
2 changes: 1 addition & 1 deletion lib/runlet/cmd/grep.ex
Expand Up @@ -16,7 +16,7 @@ defmodule Runlet.Cmd.Grep do
%Runlet.Event{event: e} = t, re ->
case e
|> to_bin()
|> Enum.any?(fn x -> Regex.match?(re, x) end) do
|> Enum.any?(&Regex.match?(re, &1)) do
true -> {[t], re}
false -> {[], re}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/runlet/ctrl/history_user.ex
Expand Up @@ -44,7 +44,7 @@ defmodule Runlet.Ctrl.HistoryUser do
lookup(env, Path.basename(name), index)

names ->
n = names |> Enum.map(fn t -> Path.basename(t) end) |> Enum.join(", ")
n = names |> Enum.map_join(", ", &Path.basename/1)

[
%Runlet.Event{
Expand Down
8 changes: 4 additions & 4 deletions mix.exs
Expand Up @@ -4,7 +4,7 @@ defmodule Runlet.Mixfile do
def project do
[
app: :runlet,
version: "1.1.1",
version: "1.1.2",
elixir: "~> 1.9",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
Expand Down Expand Up @@ -46,9 +46,9 @@ defmodule Runlet.Mixfile do
{:gun, "~> 1.3"},
{:poison, "~> 3.1.0"},
{:vex, "~> 0.6.0"},
{:credo, "~> 1.2", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.0.0-rc.7", only: [:dev], runtime: false},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}
{:credo, "~> 1.6", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.0", only: [:dev], runtime: false},
{:ex_doc, "~> 0.24", only: :dev, runtime: false}
]
end

Expand Down

0 comments on commit cc15b78

Please sign in to comment.