aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/plumber
diff options
context:
space:
mode:
authortdro <tdro@users.noreply.github.com>2021-05-24 04:07:12 -0400
committertdro <tdro@users.noreply.github.com>2021-05-24 04:07:12 -0400
commit0a6133aefc0d8a1ea4ceed3bf66b607dca90e4d3 (patch)
treeaf56da0d572d2186640515d1c8f0d9026de97777 /.local/bin/plumber
parent977aba7d462025b6fb3a06c1e40d17cac81062f7 (diff)
downloaddotfiles-0a6133aefc0d8a1ea4ceed3bf66b607dca90e4d3.tar.gz
dotfiles-0a6133aefc0d8a1ea4ceed3bf66b607dca90e4d3.tar.bz2
dotfiles-0a6133aefc0d8a1ea4ceed3bf66b607dca90e4d3.zip
.local/bin/plumber: Fix Thesaurus
Print options, but BEAM startup time is sorta slow, not good for one offs.
Diffstat (limited to '.local/bin/plumber')
-rwxr-xr-x.local/bin/plumber41
1 files changed, 33 insertions, 8 deletions
diff --git a/.local/bin/plumber b/.local/bin/plumber
index b791adc..b555456 100755
--- a/.local/bin/plumber
+++ b/.local/bin/plumber
@@ -1,31 +1,51 @@
#! /usr/bin/env elixir
+defmodule Settings do
+ def terminal do
+ "urxvt"
+ end
+end
+
defmodule ArgParser do
def parse do
{opts, _} =
System.argv()
|> OptionParser.parse!(strict: [option: :string, text: :string])
+ options = [
+ thesaurus: "Thesaurus",
+ title_case: "Title Case",
+ kjv_lookup: "KJV Verse Lookup",
+ single_line: "Single line of text",
+ first_letter: "First letter of each word in sentence"
+ ]
+
cond do
- opts[:option] == "First letter of each word in sentence" ->
+ opts[:option] == options[:first_letter] ->
TextPlumber.firstLetterOfWordsIn(opts[:text]) |> IO.binwrite()
- opts[:option] == "Single line of text" ->
+ opts[:option] == options[:single_line] ->
TextPlumber.singleLineOf(opts[:text]) |> IO.binwrite()
- opts[:option] == "Thesaurus" ->
+ opts[:option] == options[:thesaurus] ->
TextPlumber.synonymOfFirstWordIn(opts[:text])
TextPlumber.firstWordOf(opts[:text]) |> IO.binwrite()
- opts[:option] == "KJV Verse Lookup" ->
- System.cmd("urxvt", ["-e", "sh", "-c", "kjv #{TextPlumber.singleLineOf(opts[:text])}"])
+ opts[:option] == options[:kjv_lookup] ->
+ System.cmd(Settings.terminal(), [
+ "-e",
+ "sh",
+ "-c",
+ "kjv #{TextPlumber.singleLineOf(opts[:text])}"
+ ])
+
TextPlumber.singleLineOf(opts[:text]) |> IO.binwrite()
- opts[:option] == "Title Case" ->
+ opts[:option] == options[:title_case] ->
TextPlumber.titleCaseOf(opts[:text]) |> IO.binwrite()
true ->
- "No plumber #{opts[:option] || "specified"}." |> IO.puts()
+ Enum.each(options, fn {_, value} -> IO.puts(value) end)
end
end
end
@@ -50,7 +70,12 @@ defmodule TextPlumber do
end
def synonymOfFirstWordIn(text) do
- System.cmd("urxvt", ["-e", "sh", "-c", "dict #{TextPlumber.firstWordOf(text)} | vim -"])
+ System.cmd(Settings.terminal(), [
+ "-e",
+ "sh",
+ "-c",
+ "dict -h localhost #{TextPlumber.firstWordOf(text)} 2>&1 | vim -"
+ ])
end
end