Skip to content

Commit

Permalink
Added reminders
Browse files Browse the repository at this point in the history
  • Loading branch information
riverrun committed Jul 29, 2014
1 parent b373067 commit 99422a8
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 40 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

Elixir command line app that prints out various kinds of messages.

At the moment, it just prints out random quotes, like the Unix fortune app,
but in the future, it will also be used to print out reminders.
At the moment, it prints out random quotes, like the Unix fortune app,
and reminders.

###Install

Expand All @@ -13,7 +13,7 @@ Download mensagem, change to the mensagem directory and run the following comman

###Use

At the moment, mensagem (with no arguments) only prints out random quotes.
At the moment, mensagem (with no arguments) prints out random quotes and reminders.

###Status

Expand Down
Empty file removed lib/mensagem/Reminders.txt
Empty file.
24 changes: 18 additions & 6 deletions lib/mensagem/cli.ex
Original file line number Diff line number Diff line change
@@ -1,36 +1,48 @@
defmodule Mensagem.CLI do
@moduledoc """
Print out random quotes like the Unix fortune program.
Print out random quotes, like the Unix fortune program,
and reminders.
"""

alias Mensagem.Quotes
alias Mensagem.Remind

def main(args) do
args |> parse_args |> process
end

def parse_args(args) do
parse = OptionParser.parse(args, switches: [help: :boolean],
aliases: [h: :help])
parse = OptionParser.parse(args, switches: [help: :boolean, quote: :boolean, remind: :boolean],
aliases: [h: :help, q: :quote, r: :remind])

case parse do
{[help: true], _, _} -> :help
{[quote: true], _, _} -> :quote
{[remind: true], _, _} -> :remind
_ -> []
end
end

def process([]), do: Quotes.fetch_quote |> print_quote
def process([]), do: Quotes.fetch_quote <> "\n\n" <> Remind.fetch_remind |> print_message

def process(:quote), do: Quotes.fetch_quote |> print_message

def process(:remind), do: Remind.fetch_remind |> print_message

def process(:help) do
IO.puts """
Usage: mensagem
without options: Print a random quote and reminders.
Options:
-h, --help: Help!
-h, --help: Print a help message.
-q, --quote: Print a random quote.
-r, --remind: Print reminders.
"""
System.halt(0)
end

def print_quote(quote), do: IO.puts quote
def print_message(message), do: IO.puts message

end
5 changes: 0 additions & 5 deletions lib/mensagem/quotes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,4 @@ defmodule Mensagem.Quotes do
lines = File.read!(quote_file) |> String.split("\n%\n", trim: true)
length(lines) |> :random.uniform |> :lists.nth(lines)
end

def fetch_remind() do
rem_path = Path.join(__DIR__, "Reminders.txt")
lines = File.read!(rem_path) |> String.split("\n", trim: true)
end
end
3 changes: 2 additions & 1 deletion lib/mensagem/quotes/proverbs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Call on God, but row away from the rocks.
Une journee sans rire est une journee perdue.
-- Luis Bunuel
%
If you understand, things are just as they are; if you do not understand, things are just as they are.
If you understand, things are just as they are; if you do not understand,
things are just as they are.
-- Zen saying
%
Sitting quietly, doing nothing, spring comes and the grass grows by itself.
Expand Down
86 changes: 61 additions & 25 deletions lib/mensagem/quotes/quotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Whenever you are confronted with an opponent. Conquer him with love.
Nobody can hurt me without my permission.
-- Gandhi
%
There is nothing that wastes the body like worry, and one who has any faith in God should be ashamed to worry about anything whatsoever.
There is nothing that wastes the body like worry, and one who has any faith in
God should be ashamed to worry about anything whatsoever.
-- Gandhi
%
The weak can never forgive. Forgiveness is the attribute of the strong.
Expand All @@ -25,13 +26,15 @@ We must become the change we want to see.
What do I think of Western civilisation? I think it would be a very good idea.
-- Gandhi
%
Whenever you have truth it must be given with love, or the message and the messenger will be rejected.
Whenever you have truth it must be given with love, or the message and the messenger
will be rejected.
-- Gandhi
%
An eye for eye only ends up making the whole world blind.
-- Gandhi
%
“My imperfections and failures are as much a blessing from God as my successes and my talents and I lay them both at his feet.”
“My imperfections and failures are as much a blessing from God as my successes and
my talents and I lay them both at his feet.”
-- Gandhi
%
“God has no religion”
Expand All @@ -43,31 +46,40 @@ The best way to find yourself is to lose yourself in the service of others.
Earth provides enough to satisfy every man's need, but not every man's greed.
-- Gandhi
%
The Roots of Violence: Wealth without work, Pleasure without conscience, Knowledge without character, Commerce without morality, Science without humanity, Worship without sacrifice, Politics without principles.
The Roots of Violence: Wealth without work, Pleasure without conscience, Knowledge
without character, Commerce without morality, Science without humanity, Worship
without sacrifice, Politics without principles.
-- Gandhi
%
You can chain me, you can torture me, you can even destroy this body, but you will never imprison my mind.
You can chain me, you can torture me, you can even destroy this body, but you will
never imprison my mind.
-- Gandhi
%
Men often become what they believe themselves to be. If I believe I cannot do something, it makes me incapable of doing it. But when I believe I can, then I acquire the ability to do it even if I didn't have it in the beginning.
Men often become what they believe themselves to be. If I believe I cannot do something,
it makes me incapable of doing it. But when I believe I can, then I acquire the ability
to do it even if I didn't have it in the beginning.
-- Gandhi
%
The most heinous and the most cruel crimes of which history has record have been committed under the cover of religion or equally noble motives.
The most heinous and the most cruel crimes of which history has record have been committed
under the cover of religion or equally noble motives.
-- Gandhi
%
The difference between what we do and what we are capable of doing would suffice to solve most of the world's problems.
The difference between what we do and what we are capable of doing would suffice to solve
most of the world's problems.
-- Gandhi
%
Almost everything you do will seem insignificant, but it is important that you do it.
-- Gandhi
%
If I have the belief that I can do it, I shall surely acquire the capacity to do it even if I may not have it at the beginning.
If I have the belief that I can do it, I shall surely acquire the capacity to do it
even if I may not have it at the beginning.
-- Gandhi
%
Intolerance betrays want of faith in one's cause.
-- Gandhi
%
An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it.
An error does not become truth by reason of multiplied propagation, nor does truth
become error because nobody sees it.
-- Gandhi
%
Faith... Must be enforced by reason...When faith becomes blind it dies.
Expand All @@ -85,7 +97,8 @@ The greatness of a nation and its moral progress can be judged by the way its an
They cannot take away our self-respect if we do not give it to them.
-- Gandhi
%
Prayer is not asking. It is a longing of the soul. It is daily admission of one's weakness. It is better in prayer to have a heart without words than words without a heart.
Prayer is not asking. It is a longing of the soul. It is daily admission of one's
weakness. It is better in prayer to have a heart without words than words without a heart.
-- Gandhi
%
In prayer it is better to have a heart without words than words without a heart.
Expand All @@ -100,7 +113,8 @@ Non-violence and truth are inseparable and presuppose one another.
A religion that takes no account of practical affairs and does not help to solve them is no religion.
-- Gandhi
%
What difference does it make to the dead, the orphans, and the homeless, whether the mad destruction is wrought under the name of totalitarianism or the holy name of liberty or democracy?
What difference does it make to the dead, the orphans, and the homeless, whether
the mad destruction is wrought under the name of totalitarianism or the holy name of liberty or democracy?
-- Gandhi
%
Wisdom lies neither in fixity nor in change, but in the dialectic between the two.
Expand All @@ -112,49 +126,70 @@ Solitude is the profoundest fact of the human condition. Man is the only being w
Deserve your dream.
-- Octavio Paz
%
Man does not speak because he thinks; he thinks because he speaks. Or rather, speaking is no different than thinking: to speak is to think.
Man does not speak because he thinks; he thinks because he speaks. Or rather,
speaking is no different than thinking: to speak is to think.
-- Octavio Paz
%
What sets worlds in motion is the interplay of differences, their attractions and repulsions. Life is plurality, death is uniformity. By suppressing differences and pecularities, by eliminating different civilizations and cultures, progress weakens life and favors death. The ideal of a single civilization for everyone, implicit in the cult of progress and technique, impoverishes and mutilates us. Every view of the world that becomes extinct, every culture that disappears, diminishes a possibility of life.
What sets worlds in motion is the interplay of differences, their attractions
and repulsions. Life is plurality, death is uniformity. By suppressing differences
and pecularities, by eliminating different civilizations and cultures, progress
weakens life and favors death. The ideal of a single civilization for everyone,
implicit in the cult of progress and technique, impoverishes and mutilates us.
Every view of the world that becomes extinct, every culture that disappears,
diminishes a possibility of life.
-- Octavio Paz
%
Today we all speak, if not the same tongue, the same universal language. There is no one center, and time has lost its former coherence: East and West, yesterday and tomorrow exist as a confused jumble in each one of us. Different times and different spaces are combined in a here and now that is everywhere at once.
Today we all speak, if not the same tongue, the same universal language. There is no
one center, and time has lost its former coherence: East and West, yesterday and
tomorrow exist as a confused jumble in each one of us. Different times and different
spaces are combined in a here and now that is everywhere at once.
-- Octavio Paz
%
We are condemned to kill time, thus we die bit by bit.
-- Octavio Paz
%
Modern man likes to pretend that his thinking is wide-awake. But this wide-awake thinking has led us into the mazes of a nightmare in which the torture chambers are endlessly repeated in the mirrors of reason.
Modern man likes to pretend that his thinking is wide-awake. But this wide-awake
thinking has led us into the mazes of a nightmare in which the torture chambers
are endlessly repeated in the mirrors of reason.
-- Octavio Paz
%
Social criticism begins with grammar and the re-establishing of meanings.
-- Octavio Paz
%
If we are a metaphor of the universe, the human couple is the metaphor par excellence, the point of intersection of all forces and the seed of all forms. The couple is time recaptured, the return to the time before time.
If we are a metaphor of the universe, the human couple is the metaphor par excellence,
the point of intersection of all forces and the seed of all forms. The couple is
time recaptured, the return to the time before time.
-- Octavio Paz
%
Technology is not an image of the world but a way of operating on reality. The nihilism of technology lies not only in the fact that it is the most perfect expression of the will to power... but also in the fact that it lacks meaning.
Technology is not an image of the world but a way of operating on reality. The nihilism
of technology lies not only in the fact that it is the most perfect expression
of the will to power... but also in the fact that it lacks meaning.
-- Octavio Paz
%
Writers, you know, are the beggars of Western society.
-- Octavio Paz
%
The North American system only wants to consider the positive aspects of reality. Men and women are subjected from childhood to an inexorable process of adaptation; certain principles, contained in brief formulas are endlessly repeated by the Press, the radio, the churches, and the schools, and by those kindly, sinister beings, the North American mothers and wives. A person imprisoned by these schemes is like a plant in a flowerpot too small for it: he cannot grow or mature.
The North American system only wants to consider the positive aspects of reality.
Men and women are subjected from childhood to an inexorable process of adaptation;
certain principles, contained in brief formulas are endlessly repeated by the Press,
the radio, the churches, and the schools, and by those kindly, sinister beings,
the North American mothers and wives. A person imprisoned by these schemes
is like a plant in a flowerpot too small for it: he cannot grow or mature.
-- Octavio Paz
%
Art is an invention of aesthetics, which in turn is an invention of philosophers... What we call art is a game.
-- Octavio Paz
%
Literature is the expression of a feeling of deprivation, a recourse against a sense of something missing. But the contrary is also true: language is what makes us human. It is a recourse against the meaningless noise and silence of nature and history.
Literature is the expression of a feeling of deprivation, a recourse against a
sense of something missing. But the contrary is also true: language is what makes us human.
It is a recourse against the meaningless noise and silence of nature and history.
-- Octavio Paz
%
To read a poem is to hear it with our eyes; to hear it is to see it with our ears.
-- Octavio Paz
%
A glass pitcher, a wicker basket, a tunic of coarse cotton cloth. Their beauty is inseparable from their function. Handicrafts belong to a world existing before the separation of the useful and the beautiful.
-- Octavio Paz
%
Never think there is anything impossible for the soul. It is the greatest heresy to think so. If there is sin, this is the only sin — to say that you are weak, or others are weak.
Never think there is anything impossible for the soul. It is the greatest heresy
to think so. If there is sin, this is the only sin — to say that you are weak, or others are weak.
-- Swami Vivekananda
%
The first sign that you are becoming religious is that you are becoming cheerful.
Expand All @@ -163,6 +198,7 @@ The first sign that you are becoming religious is that you are becoming cheerful
The greatest religion is to be true to your own nature. Have faith in yourselves!
-- Swami Vivekananda
%
The whole secret of existence is to have no fear. Never fear what will become of you, depend on no one. Only the moment you reject all help are you free.
The whole secret of existence is to have no fear. Never fear what will become of you,
depend on no one. Only the moment you reject all help are you free.
-- Swami Vivekananda
%
14 changes: 14 additions & 0 deletions lib/mensagem/remind.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defmodule Mensagem.Remind do
@moduledoc false

def fetch_remind() do
rem_path = Path.join(__DIR__, "Reminders.txt")
#lines = File.read!(rem_path) |> String.split("\n", trim: true)
text = File.read! rem_path

case text do
[] -> "No reminders."
_ -> "Reminders for today.\n" <> text
end
end
end
2 changes: 2 additions & 0 deletions lib/mensagem/reminders.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Feed the pet ant at 5pm
Greet the wife on 2014/9/12

0 comments on commit 99422a8

Please sign in to comment.