aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/plumber
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/plumber')
-rwxr-xr-x.local/bin/plumber34
1 files changed, 34 insertions, 0 deletions
diff --git a/.local/bin/plumber b/.local/bin/plumber
new file mode 100755
index 0000000..0c575b9
--- /dev/null
+++ b/.local/bin/plumber
@@ -0,0 +1,34 @@
+#! /usr/bin/env elixir
+
+defmodule ArgParser do
+ def parse do
+ {opts, _} =
+ System.argv()
+ |> OptionParser.parse!(strict: [option: :string, text: :string])
+
+ cond do
+ opts[:option] == "First letter of each word in sentence" ->
+ TextPlumber.firstLetterOfWordsIn(opts[:text])
+
+ opts[:option] == "Single line of text" ->
+ TextPlumber.singleLineOf(opts[:text])
+
+ true ->
+ "No plumber specified #{opts[:option]}" |> IO.puts()
+ end
+ end
+end
+
+defmodule TextPlumber do
+ def firstLetterOfWordsIn(text) do
+ String.replace(text, ~r/(\w)\w*/, "\\1", global: true)
+ |> String.replace(~r/\s\s+/, " ", global: true)
+ |> IO.puts()
+ end
+
+ def singleLineOf(text) do
+ String.replace(text, "\n", "") |> IO.puts()
+ end
+end
+
+ArgParser.parse()