Current section
Files
Jump to
Current section
Files
lib/l42fu.ex
defmodule L42fu do
alias L42fu.{Commands, Error, Tools}
alias Commands.{Echo, Move}
@doc ~S"""
main entry into functional part, the calling script passes the list of arguments which come
from the commandline and can have stdin lines appended
We dispatch on subcommands
"""
def main(args),
do: args |> Tools.partition_args() |> _dispatch!() |> List.flatten() |> Enum.join("\n")
defp _dispatch!(args) do
case _dispatch(args) do
{:ok, output} -> output
{:error, message} -> raise Error, message
end
end
defp _dispatch(args)
defp _dispatch({"echo", options, args}), do: Echo.echo(args, options)
defp _dispatch({"mv", options, args}), do: Move.move(args, options)
defp _dispatch({"move", options, args}), do: Move.move(args, options)
end
# SPDX-License-Identifier: Apache-2.0