Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-12-05 14:00:23 -0800
committerCatalin Mititiuc <webdevcat@proton.me>2024-12-05 14:40:37 -0800
commit6fc8e8ec192051938da4d31459698d55b1e40ea2 (patch)
tree351a1e949c6d1d075370cdbd6a951f94eb43df87 /lib/mix/tasks/pandoc.ex
parentd9dd7e8cadebf41581d341aac3ce2b647bd7ad0a (diff)
Get path data from config vars
Diffstat (limited to 'lib/mix/tasks/pandoc.ex')
-rw-r--r--lib/mix/tasks/pandoc.ex34
1 files changed, 28 insertions, 6 deletions
diff --git a/lib/mix/tasks/pandoc.ex b/lib/mix/tasks/pandoc.ex
index fe93208..4da8bf1 100644
--- a/lib/mix/tasks/pandoc.ex
+++ b/lib/mix/tasks/pandoc.ex
@@ -1,16 +1,38 @@
defmodule Mix.Tasks.Pandoc do
use Mix.Task
- @out_dir "priv/static"
-
@impl true
- def run([profile | _args]) do
- IO.puts "profile: #{profile}"
+ def run(args) do
+ switches = [runtime_config: :boolean]
+ {opts, remaining_args} = OptionParser.parse_head!(args, switches: switches)
+
+ if opts[:runtime_config] do
+ Mix.Task.run("app.config")
+ else
+ Mix.Task.run("loadpaths")
+ Application.ensure_all_started(:pandoc)
+ end
+
+ Mix.Task.reenable("pandoc")
+ install_and_run(remaining_args)
+ end
- "priv/posts"
+ defp install_and_run([profile | args] = _all) do
+ IO.puts("mix task args #{inspect(args)}")
+
+ "documents"
|> File.ls!()
|> Enum.each(fn path ->
- Pandoc.install_and_run(Path.join(["priv", "posts", path]))
+ all = [profile, path]
+
+ case Pandoc.run(String.to_atom(profile), [path]) do
+ 0 -> :ok
+ status -> Mix.raise("`mix pandoc #{Enum.join(all, " ")}` exited with #{status}")
+ end
end)
end
+
+ defp install_and_run([]) do
+ Mix.raise("`mix pandoc` expects the profile as argument")
+ end
end