#!/usr/bin/env perl
package
local
::bin::avemaria;
binmode
(STDOUT,
":utf8"
);
$|++;
my
$Rosary
= Webservice::Rosary::API->new;
our
$VERSION
=
$Webservice::Rosary::API::VERSION
;
EXIT_SUCCESS
=> 0,
EXIT_ERROR
=> 1,
};
my
$subcommand
=
shift
@ARGV
;
dispatch {
my
(
$Rosary
,
$subcommand
,
$ARGV
) = xshift_and_deref
@_
;
my
@mp3
=
qw/today yesterday tomorrow random/
;
my
@day
=
qw/sunday monday tuesday wednesday thursday friday saturday/
;
my
@mystery
=
qw/joyful glorious sorrowful luminous/
;
return
"day"
if
(not
$subcommand
);
return
"mp3"
if
(
grep
{ m/^
$subcommand
$/i }
@mp3
);
return
"day"
if
(
grep
{ m/^
$subcommand
$/i }
@day
);
return
"mystery"
if
(
grep
{ m/^
$subcommand
$/i }
@mystery
);
return
"help"
if
(
grep
{ m/^
$subcommand
/i }
qw/-h help mystery/
) or (
$subcommand
=~ m/^-/);
return
"about"
if
(
grep
{ m/^
$subcommand
$/i }
qw/about -a/
);
return
"help"
;
} [
$Rosary
,
lc
$subcommand
, \
@ARGV
],
day
=> \
&PrayTheRosary
,
mp3
=> \
&do_mp3
,
about
=> \
&do_about
,
help
=> \
&do_help
,
mystery
=> \
&mystery
,
;
sub
do_mp3 {
my
(
$Rosary
,
$subcommand
,
$ARGV
) = xshift_and_deref
@_
;
say
$Rosary
->mp3Link(
$subcommand
,
$ARGV
);
exit
EXIT_SUCCESS;
}
sub
do_about() {
return
print
<<EOF;
# BACKGROUND ON THE ROSARY
The Rosary is a traditional Catholic prayer devotion that involves the
repetition of prayers and meditation on key events from the lives of Jesus
Christ and the Virgin Mary. The prayer is structured around a set of beads,
each representing a specific prayer. These include the Our Father, Hail Mary,
and Glory Be, which are recited while reflecting on the Mysteries-twenty
key moments in the lives of Jesus and Mary, grouped into four categories:
the Joyful, Sorrowful, Glorious, and Luminous Mysteries. The Rosary is both
a contemplative prayer and a way to focus on the essential aspects of the
Catholic faith, helping the faithful deepen their relationship with God.
The history of the Rosary dates back to the Middle Ages, with its roots often
linked to St. Dominic, who is traditionally credited with receiving the Rosary
from the Virgin Mary in the 13th century. The Rosary evolved over several
centuries. One of its early forms was connected to the Psalter of Our Lady,
where the faithful would pray 150 Hail Marys, reflecting the 150 Psalms of
the Old Testament. This practice was common among laypeople who could not
read the Psalms themselves but still wanted to engage in a structured form
of prayer. Over time, the Rosary's prayers and structure were refined, and
by the 16th century, it became formally established by the Catholic Church
as a central devotion, with the mysteries of the Rosary added to provide a
scriptural basis for the prayers.
## Biblical Foundations of the Hail Mary
For Catholics, the Rosary is a deeply meaningful prayer practice that helps
them draw closer to God by reflecting on the pivotal moments of salvation
history. Its biblical foundations are grounded in scripture, with the Hail Mary
drawn from the Angel Gabriel's greeting to Mary in Luke 1:28 and Elizabeth's
words in Luke 1:42.
The first part of the Hail Mary comes from Luke 1:28 and Luke 1:42 in the
Douay-Rheims translation:
> And the angel being come in, said unto her: Hail, full of grace, the Lord
> is with thee: blessed art thou among women.
and:
> And she cried out with a loud voice, and said: Blessed art thou among women,
> and blessed is the fruit of thy womb.
These biblical words form the Angelic Salutation, which Catholics begin the
Hail Mary with:
> Hail Mary, full of grace, the Lord is with thee: blessed art thou
> among women, and blessed is the fruit of thy womb, Jesus.
## The Second Part of the Hail Mary
The second part of the Hail Mary, which was added later to the prayer,
invokes Mary's intercession. This part is drawn from the Catholic tradition
and reflects the Church's desire for Mary's prayers to be a source of strength
and protection for all the faithful. The second part reads:
> Holy Mary, Mother of God, pray for us sinners, now and at the hour
> of our death. Amen.
This petition is based on Mary's role as Mother of God (as declared in Luke
1:43, when Elizabeth calls her the "Mother of my Lord") and her ongoing role
as intercessor for the Church. It is the second part of the Hail Mary that
Catholics use to seek her intercession, especially in times of trial.
## The Our Father
The Our Father comes directly from Jesus' teaching in the Gospel of Matthew
6:9-13:
> Thus therefore shall you pray: Our Father who art in heaven, hallowed be Thy
> name. Thy kingdom come. Thy will be done, on earth as it is in heaven. Give
> us this day our daily bread. And forgive us our trespasses, as we forgive
> those who trespass against us. And lead us not into temptation, but deliver
> us from evil. Matthew 6:9-13.
By meditating on the Mysteries of the Rosary, Catholics invite the presence
of Jesus into their lives, contemplating His birth, death, resurrection, and
the role of Mary in His story. These meditations, grouped into the Joyful,
Sorrowful, Glorious, and Luminous Mysteries, help to guide the faithful
through the essential moments of Christ's life and His salvation work.
## The Rosary as a Communal Devotion
The Rosary is seen not just as a personal prayer, but as a communal devotion
that fosters a deeper understanding of God's love and a powerful means of
seeking His intercession. It is often prayed in groups, in parishes, or even
in families, helping to build unity within the faith community. Through its
rich combination of prayer and meditation, the Rosary has become a beloved
devotion for Catholics around the world, encouraging spiritual growth and
reflection on the central mysteries of the Christian faith.
The importance of daily prayer of the Rosary was emphasized by Our Lady
during the Apparitions at Fatima in 1917, where she specifically urged the
children to "pray the Rosary every day" for peace in the world and for the
salvation of souls, making it a call for all the faithful to embrace this
prayer as a tool for spiritual strength and intercession. For more information
on Fatima, look up, "the Miracle of the Sun."
+Deo Gratias+
EOF
exit
EXIT_SUCCESS;
}
sub
do_help() {
return
print
<<EOF;
avemaria - commandline Rosary client for DailyRosary.cf and TheRosaryAPI.cf
VERSION $Webservice::Rosary::API::VERSION
Note: Commandline options may change to accomodate feedback. This note will
be removed once the cli UX settles.
Quick Start
> avemaria # no arguments
> ... runs through the recitation of the Rosary for today, equivalent,
to,
> avemaria \$(date "+%A") --pray -t # `date` commands prints out today's day of week
Getting Help
> avemaria help
> ... prints help section
Learning More
> avemaria about
> ... prints an "about" section
Functional Commands
There are 2 types of commands. One set of commands returns a URL for an MP3,
which may then be piped into another program to download it. The other set
of commands displays the specified Mystery (by day of the week or actual
name of the Mystery), so that the user may be guided through the specified
Mystery of the Rosary - from start to finish.
Usage - to print MP3 URL to STDIN:
avemaria today | yesterday | tomorrow | random
Example 1,
> avemaria today
Example 2,
> curl -O \$(avemaria random) -w "\\nDownloaded file: %{filename_effective}\\n"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 31.5M 100 31.5M 0 0 2374k 0 0:00:13 0:00:13 --:--:-- 5043k
Downloaded file: audio-rosary-sorrowful-mysteries.mp3
>
Note, MP3 Sources are as follows:
Usage - to Pray the Rosary in the commandline:
avemaria DAY_OR_MYSTERY [--pray] [-i] [-t] [--fully] [--sleep=0.N]
Valid DAY_OR_MYSTERY values:
Joyful, Sorrowful, Luminous, Glorious, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, or Saturday
Optional flags:
--pray : automatically prints prayers, character by character to the screen; default delay is 0.4 seconds.
-i : user must hit <RETURN> after each prayer (and description, if used with "--fully"
-t : user must hit <RETURN> after each description (requires --fully)
--fully : prints the full description of the current Mystery's Decade, including the Fruit of the Mystery
--sleep : affects the delay taken before each new character is printed (when used with --pray). Default is 0.4 seconds.
Example 3,
Used without additional options, it just prints the name of the Mystery
> avemaria Monday
> Monday - The Joyful Mysteries
>
> avemaria Sorrowful
> Friday - The Sorrowful Mysteries
>
Example 4,
> avemaria Friday --pray -t --fully
> .. clears screen, the plays the specified Mystery (Sorrowful in this case),
while pausing only at the beginning of each Mystery after the description has
been printed ...
Example 5,
Run with absolutely no subcommands or flags, runs "--pray" for Today's Mystery,
> avemaria
> .. clears screen, the plays the specified Mystery for Today ...
Feedback is Requested.
I have no idea how this is going to be used, and the way someone says the Rosary
tends to be highly personal; so please let me know what kind of "--pray" controls
would be helpful.
+Deo Gratias+
VERSION $Webservice::Rosary::API::VERSION
avemaria - commandline Rosary client for DailyRosary.cf and TheRosaryAPI.cf
EOF
exit
EXIT_SUCCESS;
}
sub
mystery {
my
(
$Rosary
,
$subcommand
,
$ARGV
) = xshift_and_deref
@_
;
my
$Convert
= h2o {
luminous
=>
"thursday"
,
sorrowful
=>
"friday"
,
joyful
=>
"saturday"
,
glorious
=>
"sunday"
,
};
$subcommand
=
$Convert
->
$subcommand
;
return
PrayTheRosary([
$Rosary
,
$subcommand
,
$ARGV
]);
}
sub
_print($$) {
my
(
$Text
,
$o
) =
@_
;
my
@words
=
split
//,
$Text
;
foreach
my
$Word
(
@words
) {
printf
"%s"
,
$Word
;
sleep
$o
->
sleep
;
}
return
;
}
sub
PrayTheRosary {
my
(
$Rosary
,
$subcommand
,
$ARGV
) = xshift_and_deref
@_
;
my
@days_of_week
=
qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday)
;
my
(
$sec
,
$min
,
$hour
,
$mday
,
$mon
,
$year
,
$wday
) =
localtime
();
$subcommand
||=
lc
$days_of_week
[
$wday
];
$ARGV
= (
@$ARGV
) ?
$ARGV
: [
'--pray'
];
my
$o
= Getopt2h2o
$ARGV
, {
sleep
=> 0.04 },
qw/pray i t fully without sleep=s/
;
my
$Mystery
=
$Rosary
->day(
$subcommand
,
$ARGV
);
my
$Full
;
if
(
$o
->fully) {
$Full
=
$Rosary
->details(
lc
$Mystery
->group_by);
}
my
$Name
=
sprintf
"%s - The %s Mysteries"
,
ucfirst
$subcommand
,
$Mystery
->group_by;
unless
(
$o
->pray) {
say
$Name
;
exit
EXIT_SUCCESS;
}
my
@Prayers
=
qw/In_The_Name_1 I_Believe Our__Father_1 Hail__Mary_1 Hail__Mary_2 Hail__Mary_3 Glory_Be_1 Oh_My_Jesus_1/
;
my
$Decade
= 0;
my
$Announce
= 0;
my
$Pater_Noster
= 1;
my
$Ave_Maria
= 3;
my
$Gloria_Patria
= 1;
my
$O_Mi_Jesu
= 1;
foreach
my
$D
(1..5) {
push
@Prayers
,
sprintf
"Announce_%d"
, ++
$Announce
;
push
@Prayers
,
sprintf
"Our__Father_%d"
, ++
$Pater_Noster
;
foreach
my
$I
(1..10) {
push
@Prayers
,
sprintf
"Hail__Mary_%d_%d"
, ++
$Ave_Maria
,
$I
;
}
push
@Prayers
,
sprintf
"Glory_Be_%d"
, ++
$Gloria_Patria
;
push
@Prayers
,
sprintf
"Oh_My_Jesus_%d"
, ++
$O_Mi_Jesu
;
}
push
@Prayers
,
qw/Holy_Queen Pray_For_Us_Most_Holy_Mother_of_God Oremus Final_Prayer Most_Holy_Rosary In_The_Name_2/
;
$Mystery
= tr4h2o o2d
$Mystery
;
$Mystery
->{pray_for_us_most_holy_mother_of_god} =
<<EOF;
V. Pray for us, Oh Holy Mother of God
R. That we may be made worth of the promises of Christ.
EOF
$Mystery
->{oremus} =
"V. Let us Pray."
;
$Mystery
->{most_holy_rosary} =
""
;
$Mystery
->{in_the_name_2} =
sprintf
"The Most Holy Rosary.\n%s"
.
$Mystery
->{in_the_name_2};
h2o
$Mystery
;
my
$count
= 0;
my
$decade
= 0;
foreach
my
$Prayer
(
map
{
lc
}
@Prayers
) {
my
$Text
=
$Mystery
->
$Prayer
;
$Text
=~ s/\\r\\n|\\n/\n/g;
$Text
=~ s/Lead/\nLead/;
sleep
0.75;
print
"\033[2J\033[H"
;
my
$align
=
sprintf
"%30s "
,
$Name
;
printf
"%s[%-2d of %d]\n\n"
,
$align
, ++
$count
,
scalar
@Prayers
;
if
(
$o
->fully and
$Prayer
=~ m/Announce/i) {
my
$details
=
$Full
->[
$decade
++];
_print
$details
->title,
$o
;
print
"\n\n"
;
_print fold_text(
$details
->text, 72),
$o
;
print
"\n\n"
;
_print
$details
->fruit,
$o
;
print
"\n\n"
;
if
(
$o
->i or
$o
->t) {
print
"\n\n<RETURN> to continue ... "
;
my
$next
= <STDIN>
}
}
_print
$Text
,
$o
;
if
(
$o
->i) {
print
"\n\n<RETURN> to continue ... "
;
my
$next
= <STDIN>
}
}
exit
EXIT_SUCCESS;
}
123