]>
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>
19 #include "private-moo.h"
20 #include "private-output.h"
25 std::string
getMooLine() { /*{{{*/
26 time_t const timenow
= time(NULL
);
28 localtime_r(&timenow
, &special
);
29 enum { NORMAL
, PACKAGEMANAGER
, APPRECIATION
, AGITATION
, AIRBORN
} line
;
30 if (special
.tm_mon
== 11 && special
.tm_mday
== 25)
31 line
= PACKAGEMANAGER
;
32 else if (special
.tm_mon
== 7 && special
.tm_mday
== 16)
34 else if (special
.tm_mon
== 10 && special
.tm_mday
== 7)
36 else if (special
.tm_mon
== 1 && special
.tm_mday
== 18)
41 bool const quiet
= _config
->FindI("quiet") >= 2;
42 std::ostringstream out
;
48 case PACKAGEMANAGER
: out
<< "Happy package management day!"; break;
49 case APPRECIATION
: out
<< "Three moos for Debian!"; break;
50 case AGITATION
: out
<< "Whoever needs milk, bows to the animal."; break;
51 case AIRBORN
: out
<< "It's a Bird ... It's a Plane ... It's Super Cow!"; break;
52 default: out
<< "Have you mooed today?"; break;
58 out
<< "\"..." << std::endl
;
63 bool printMooLine() { /*{{{*/
64 std::cerr
<< getMooLine() << std::endl
;
68 bool DoMoo1(CommandLine
&CmdL
) /*{{{*/
70 // our trustworthy super cow since 2001
71 if (_config
->FindI("quiet") >= 2)
72 return printMooLine();
73 std::string
const moo
= getMooLine();
74 size_t const depth
= moo
.length()/4;
76 OutputInDepth(depth
, " ") << " (__) \n" <<
77 OutputInDepth(depth
, " ") << " (oo) \n" <<
78 OutputInDepth(depth
, " ") << " /------\\/ \n" <<
79 OutputInDepth(depth
, " ") << " / | || \n" <<
80 OutputInDepth(depth
, " ") << " * /\\---/\\ \n" <<
81 OutputInDepth(depth
, " ") << " ~~ ~~ \n" <<
86 bool DoMoo2(CommandLine
&CmdL
) /*{{{*/
88 // by Fernando Ribeiro in lp:56125
89 if (_config
->FindI("quiet") >= 2)
90 return printMooLine();
91 std::string
const moo
= getMooLine();
92 size_t const depth
= moo
.length()/4;
93 if (_config
->FindB("APT::Moo::Color", false) == false)
95 OutputInDepth(depth
, " ") << " (__) \n" <<
96 OutputInDepth(depth
, " ") << " _______~(..)~ \n" <<
97 OutputInDepth(depth
, " ") << " ,----\\(oo) \n" <<
98 OutputInDepth(depth
, " ") << " /|____|,' \n" <<
99 OutputInDepth(depth
, " ") << " * /\"\\ /\\ \n" <<
100 OutputInDepth(depth
, " ") << " ~ ~ ~ ~ \n" <<
105 OutputInDepth(depth
, " ") << " \033[1;97m(\033[0;33m__\033[1;97m)\033[0m\n" <<
106 OutputInDepth(depth
, " ") << " \033[31m_______\033[33m~(\033[1;34m..\033[0;33m)~\033[0m\n" <<
107 OutputInDepth(depth
, " ") << " \033[33m,----\033[31m\\\033[33m(\033[1;4;35moo\033[0;33m)\033[0m\n" <<
108 OutputInDepth(depth
, " ") << " \033[33m/|____|,'\033[0m\n" <<
109 OutputInDepth(depth
, " ") << " \033[1;5;97m*\033[0;33m /\\ /\\\033[0m\n" <<
111 for (size_t i
= moo
.length()/2; i
> 1; --i
)
114 c1out
<< "w\033[0m\n" << moo
;
120 bool DoMoo3(CommandLine
&CmdL
) /*{{{*/
122 // by Robert Millan in deb:134156
123 if (_config
->FindI("quiet") >= 2)
124 return printMooLine();
125 std::string
const moo
= getMooLine();
126 size_t const depth
= moo
.length()/16;
128 OutputInDepth(depth
, " ") << " \\_/ \n" <<
129 OutputInDepth(depth
, " ") << " m00h (__) -(_)- \n" <<
130 OutputInDepth(depth
, " ") << " \\ ~Oo~___ / \\\n" <<
131 OutputInDepth(depth
, " ") << " (..) |\\ \n" <<
132 OutputInDepth(depth
, "_") << "_________|_|_|__________" <<
133 OutputInDepth((moo
.length() - (depth
+ 27)), "_") << "\n" << moo
;
137 bool DoMooApril(CommandLine
&CmdL
) /*{{{*/
139 // by Christopher Allan Webber and proposed by Paul Tagliamonte
140 // in a "Community outreach": https://lists.debian.org/debian-devel/2013/04/msg00045.html
141 if (_config
->FindI("quiet") >= 2)
143 std::cerr
<< "Have you smashed some milk today?" << std::endl
;
149 " )___ _ Have you smashed some milk today?\n"
152 " //( ',__,' \\ (' ')\n"
160 bool DoMoo(CommandLine
&CmdL
) /*{{{*/
162 time_t const timenow
= time(NULL
);
164 localtime_r(&timenow
, &april
);
165 if (april
.tm_mday
== 1 && april
.tm_mon
== 3)
166 return DoMooApril(CmdL
);
168 signed short SuperCow
= 1;
169 if (CmdL
.FileSize() != 0)
170 for (const char **Moo
= CmdL
.FileList
+ 1; *Moo
!= 0; Moo
++)
171 if (strcasecmp(*Moo
, "moo") == 0)
174 // time is random enough for our purpose
177 if (april
.tm_sec
== 1)
178 SuperCow
= 1 + (timenow
% 4);
180 SuperCow
= 1 + (timenow
% 3);
184 case 1: return DoMoo1(CmdL
);
185 case 2: return DoMoo2(CmdL
);
186 case 3: return DoMoo3(CmdL
);
187 case 4: return DoMooApril(CmdL
);
188 default: return DoMoo1(CmdL
);