1 #Region "Microsoft.VisualBasic::96152bd9a4e2478911dd455ba82b3d8b, Microsoft.VisualBasic.Core\Language\Language\UnixBash\Cowsay.vb"
2
3     ' Author:
4     
5     '       asuka (amethyst.asuka@gcmodeller.org)
6     '       xie (genetics@smrucc.org)
7     '       xieguigang (xie.guigang@live.com)
8     
9     ' Copyright (c) 2018 GPL3 Licensed
10     
11     
12     ' GNU GENERAL PUBLIC LICENSE (GPL3)
13     
14     
15     ' This program is free software: you can redistribute it and/or modify
16     ' it under the terms of the GNU General Public License as published by
17     ' the Free Software Foundation, either version 3 of the License, or
18     ' (at your option) any later version.
19     
20     ' This program is distributed in the hope that it will be useful,
21     ' but WITHOUT ANY WARRANTY; without even the implied warranty of
22     ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23     ' GNU General Public License for more details.
24     
25     ' You should have received a copy of the GNU General Public License
26     ' along with this program. If not, see <http://www.gnu.org/licenses/>.
27
28
29
30     ' /********************************************************************************/
31
32     ' Summaries:
33
34     '     Module CowsayTricks
35     
36     '         Function: __msgbox, RunCowsay
37     
38     
39     ' /********************************************************************************/
40
41 #End Region
42
43 Imports System.Text
44 Imports Microsoft.VisualBasic.CommandLine.Reflection
45 Imports Microsoft.VisualBasic.Scripting.MetaData
46
47 Namespace Language.UnixBash
48
49     ''' <summary>
50     ''' Cowsay tricks for showing your message more friendly.
51     ''' </summary>
52     <Package("Cowsay",
53                   Description:="cowsay is a program which generates ASCII pictures of a cow with a message.[2] 
54                   It can also generate pictures using pre-made images of other animals, such as Tux the Penguin, the Linux mascot. 
55                   It is written in Perl. There is also a related program called cowthink, with cows with thought bubbles rather than speech bubbles. .
56                   cow files for cowsay exist which are able to produce different variants of ""cows"", with different kinds of ""eyes"", 
57                   and so forth.[3] It is sometimes used on IRC, desktop screenshots, and in software documentation. 
58                   It is more or less a joke within hacker culture, but has been around long enough that its use is rather widespread. 
59                   In 2007 it was highlighted as a Debian package of the day.
60                   Cowsay tricks for showing your message more friendly. https://en.wikipedia.org/wiki/Cowsay",
61                   Revision:=21,
62                   Publisher:="<a href=""mailto://xie.guigang@live.com"">xie.guigang@live.com</a>",
63                   Url:="http://gcmodeller.org",
64                   Category:=APICategories.UtilityTools)>
65     Public Module CowsayTricks
66
67         ''' <summary>
68         ''' Normal cow
69         ''' </summary>
70         Public Const NormalCow As String =
71 "          |
72           |    ^__^
73            --  (oo)\_______
74                (__)\       )\\
75                    ||----W |
76                    ||     ||
77 "
78
79         ''' <summary>
80         ''' The cow in dead face
81         ''' </summary>
82         Public Const DeadCow As String =
83 "          |
84           |    ^__^
85            --  (XX)\_______
86                (__)\       )\\
87                    ||----W |
88                    ||     ||
89 "
90
91         Public Const tux As String = " __________________
92 < This is my text. >
93  ------------------
94    \
95     \
96         .--.
97        |o_o |
98        |:_/ |
99       //   \ \
100      (|     | )
101     /'\_   _/`\
102     \___)=(___/"
103
104         Const HelloWorld As String =
105 "
106 H   H EEEEE L     L      OOO       W   W  OOO  RRRR  L     DDDD  !!
107 H   H E     L     L     O   O      W W W O   O R   R L     D   D !! 
108 HHHHH EEEEE L     L     O   O      W W W O   O RRRR  L     D   D !! 
109 H   H E     L     L     O   O  ,,   W W  O   O R   R L     D   D    
110 H   H EEEEE LLLLL LLLLL  OOO  ,,    W W   OOO  R   R LLLLL DDDD  !!
111 "
112
113         ''' <summary>
114         ''' Show cowsay with a specific input message on your console screen. you can using /dead to change its face.
115         ''' </summary>
116         ''' <param name="msg"></param>
117         ''' <returns></returns>
118         ''' 
119         <ExportAPI("Cowsay",
120                Info:="Show cowsay with a specific input message on your console screen. you can using /dead to change its face.")>
121         Public Function RunCowsay(msg As StringOptional isDead As Boolean = FalseAs String
122             If isDead Then
123                 msg = __msgbox(msg) & DeadCow
124             Else
125                 msg = __msgbox(msg) & NormalCow
126             End If
127
128             Call Console.WriteLine(msg)
129
130             Return msg
131         End Function
132
133         ''' <summary>
134         ''' Creates the message box to display the message for the cow on the console.
135         ''' </summary>
136         ''' <param name="msg"></param>
137         ''' <returns></returns>
138         Private Function __msgbox(msg As StringAs String
139             Dim l = Len(msg)
140             Dim offset As String = New String(" ", 8)
141             Dim sBuilder As StringBuilder = New StringBuilder(vbCrLf, 1024)
142             Call sBuilder.AppendLine(offset & " " & New String("_", l + 4) & " ")
143             Call sBuilder.AppendLine(offset & String.Format("<  {0}  >", msg))
144             Call sBuilder.AppendLine(offset & " " & New String("-", l + 4) & " ")
145
146             Return sBuilder.ToString
147         End Function
148     End Module
149 End Namespace