]>
git.saurik.com Git - apt.git/blob - apt-private/private-moo.cc
1 // -*- mode: cpp; mode: fold -*-
3 /* ######################################################################
5 Here be cows – but: Never ask, never tell
7 ##################################################################### */
9 // Include Files /*{{{*/
12 #include <apt-pkg/configuration.h>
13 #include <apt-pkg/cmndline.h>
14 #include <apt-pkg/strutl.h>
16 #include <apt-private/private-moo.h>
17 #include <apt-private/private-output.h>
29 static std::string
getMooLine() { /*{{{*/
30 time_t const timenow
= time(NULL
);
32 localtime_r(&timenow
, &special
);
33 enum { NORMAL
, PACKAGEMANAGER
, APPRECIATION
, AGITATION
, AIRBORN
} line
;
34 if (special
.tm_mon
== 11 && special
.tm_mday
== 25)
35 line
= PACKAGEMANAGER
;
36 else if (special
.tm_mon
== 7 && special
.tm_mday
== 16)
38 else if (special
.tm_mon
== 10 && special
.tm_mday
== 7)
40 else if (special
.tm_mon
== 1 && special
.tm_mday
== 18)
45 bool const quiet
= _config
->FindI("quiet") >= 2;
46 std::ostringstream out
;
52 case PACKAGEMANAGER
: out
<< "Happy package management day!"; break;
53 case APPRECIATION
: out
<< "Three moos for Debian!"; break;
54 case AGITATION
: out
<< "Whoever needs milk, bows to the animal."; break;
55 case AIRBORN
: out
<< "It's a Bird ... It's a Plane ... It's Super Cow!"; break;
56 default: out
<< "Have you mooed today?"; break;
62 out
<< "\"..." << std::endl
;
67 static bool printMooLine() { /*{{{*/
68 std::cerr
<< getMooLine() << std::endl
;
72 bool DoMoo1(CommandLine
&) /*{{{*/
74 // our trustworthy super cow since 2001
75 if (_config
->FindI("quiet") >= 2)
76 return printMooLine();
77 std::string
const moo
= getMooLine();
78 size_t const depth
= moo
.length()/4;
80 OutputInDepth(depth
, " ") << " (__) \n" <<
81 OutputInDepth(depth
, " ") << " (oo) \n" <<
82 OutputInDepth(depth
, " ") << " /------\\/ \n" <<
83 OutputInDepth(depth
, " ") << " / | || \n" <<
84 OutputInDepth(depth
, " ") << " * /\\---/\\ \n" <<
85 OutputInDepth(depth
, " ") << " ~~ ~~ \n" <<
90 bool DoMoo2(CommandLine
&) /*{{{*/
92 // by Fernando Ribeiro in lp:56125
93 if (_config
->FindI("quiet") >= 2)
94 return printMooLine();
95 std::string
const moo
= getMooLine();
96 size_t const depth
= moo
.length()/4;
97 if (_config
->FindB("APT::Moo::Color", false) == false)
99 OutputInDepth(depth
, " ") << " (__) \n" <<
100 OutputInDepth(depth
, " ") << " _______~(..)~ \n" <<
101 OutputInDepth(depth
, " ") << " ,----\\(oo) \n" <<
102 OutputInDepth(depth
, " ") << " /|____|,' \n" <<
103 OutputInDepth(depth
, " ") << " * /\"\\ /\\ \n" <<
104 OutputInDepth(depth
, " ") << " ~ ~ ~ ~ \n" <<
109 OutputInDepth(depth
, " ") << " \033[1;97m(\033[0;33m__\033[1;97m)\033[0m\n" <<
110 OutputInDepth(depth
, " ") << " \033[31m_______\033[33m~(\033[1;34m..\033[0;33m)~\033[0m\n" <<
111 OutputInDepth(depth
, " ") << " \033[33m,----\033[31m\\\033[33m(\033[1;4;35moo\033[0;33m)\033[0m\n" <<
112 OutputInDepth(depth
, " ") << " \033[33m/|____|,'\033[0m\n" <<
113 OutputInDepth(depth
, " ") << " \033[1;5;97m*\033[0;33m /\\ /\\\033[0m\n" <<
115 for (size_t i
= moo
.length()/2; i
> 1; --i
)
118 c1out
<< "w\033[0m\n" << moo
;
124 bool DoMoo3(CommandLine
&) /*{{{*/
126 // by Robert Millan in deb:134156
127 if (_config
->FindI("quiet") >= 2)
128 return printMooLine();
129 std::string
const moo
= getMooLine();
130 size_t const depth
= moo
.length()/16;
132 OutputInDepth(depth
, " ") << " \\_/ \n" <<
133 OutputInDepth(depth
, " ") << " m00h (__) -(_)- \n" <<
134 OutputInDepth(depth
, " ") << " \\ ~Oo~___ / \\\n" <<
135 OutputInDepth(depth
, " ") << " (..) |\\ \n" <<
136 OutputInDepth(depth
, "_") << "_________|_|_|__________" <<
137 OutputInDepth((moo
.length() - (depth
+ 27)), "_") << "\n" << moo
;
141 bool DoMooApril(CommandLine
&) /*{{{*/
143 // by Christopher Allan Webber and proposed by Paul Tagliamonte
144 // in a "Community outreach": https://lists.debian.org/debian-devel/2013/04/msg00045.html
145 if (_config
->FindI("quiet") >= 2)
147 std::cerr
<< "Have you smashed some milk today?" << std::endl
;
153 " )___ _ Have you smashed some milk today?\n"
156 " //( ',__,' \\ (' ')\n"
164 bool DoMoo(CommandLine
&CmdL
) /*{{{*/
166 time_t const timenow
= time(NULL
);
168 localtime_r(&timenow
, &april
);
169 if (april
.tm_mday
== 1 && april
.tm_mon
== 3)
170 return DoMooApril(CmdL
);
172 signed short SuperCow
= 1;
173 if (CmdL
.FileSize() != 0)
174 for (const char **Moo
= CmdL
.FileList
+ 1; *Moo
!= 0; Moo
++)
175 if (strcasecmp(*Moo
, "moo") == 0)
178 // time is random enough for our purpose
181 if (april
.tm_sec
== 1)
182 SuperCow
= 1 + (timenow
% 4);
184 SuperCow
= 1 + (timenow
% 3);
188 case 1: return DoMoo1(CmdL
);
189 case 2: return DoMoo2(CmdL
);
190 case 3: return DoMoo3(CmdL
);
191 case 4: return DoMooApril(CmdL
);
192 default: return DoMoo1(CmdL
);