Cow-ment your code

TL;DR

Being silly with cowsay.

Do you know cowsay?

$ cowsay 'Hello, world!'
 _______________
< Hello, world! >
 ---------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Too cute! I thought to make a little wrapper to produce cow-ments for code instead, so here’s cowment:

Local version here.

Use it by passing the comment you want to spice up:

$ cowment 'This section is really important, watch out!'
type: 'elephant-in-snake'

########################################################################
#  ______________________________________________
# /                                              \
# | This section is really important, watch out! |
# \                                              /
#  ----------------------------------------------
#        \
#         \  ....
#           .    ........
#           .            .
#           .             .
#     .......              .........
#     ..............................
# Elephant inside ASCII snake
#
##########################################

Then copy, paste… and you’re done! The theme is chosen randomly among the available ones in the specific installation, although you can force one by setting environment variable TYPE:

$ TYPE=milk cowment 'This section is really important, watch out!'
type: 'milk'

########################################################################
#  ______________________________________________
# /                                              \
# | This section is really important, watch out! |
# \                                              /
#  ----------------------------------------------
#  \     ____________ 
#   \    |__________|
#       /           /\
#      /           /  \
#     /___________/___/|
#     |          |     |
#     |  ==\ /== |     |
#     |   O   O  | \ \ |
#     |     <    |  \ \|
#    /|          |   \ \
#   / |  \_____/ |   / /
#  / /|          |  / /|
# /||\|          | /||\/
#     -------------|   
#         | |    | | 
#        <__/    \__>
#
##########################################

It should not be too hard to adapt it to suit your programming language… this is left as a trivial exercise for the reader 🙄

Happy cow-menting!


Comments? Octodon, , GitHub, Reddit, or drop me a line!