├── .travis.yml ├── .editorconfig ├── Makefile ├── Readme.md ├── test.sh └── dick.sh /.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | sudo: required 3 | install: sudo make install 4 | script: make test 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | indent_style = space 9 | indent_size = 2 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | [Makefile] 14 | indent_style = tab 15 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PREFIX ?= /usr/local 2 | BINPREFIX ?= "$(PREFIX)/bin" 3 | BINPATH ?= "$(PREFIX)/bin/dick" 4 | 5 | default: install 6 | 7 | install: 8 | @mkdir -p $(BINPREFIX) 9 | cp -f dick.sh $(BINPATH) 10 | @chmod a+x $(BINPATH) 11 | 12 | uninstall: 13 | rm -fr $(BINPATH) 14 | 15 | test: 16 | bash test.sh 17 | 18 | .PHONY: default install uninstall test 19 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # dick [![Build Status](https://travis-ci.org/kaime/dick.png?branch=master)](https://travis-ci.org/kaime/dick) 2 | 3 | Tired of wasting hours handcrafting ASCII dicks? Get glorious, pixel perfect dicks from the convenience of the command line. 4 | 5 | ## Installation 6 | 7 | You'll need [git](https://git-scm.com/). Install it first if you don't already have it. 8 | 9 | Clone the repository somewhere in your computer and run `make install` on it. On a terminal, type: 10 | 11 | ``` 12 | git clone https://github.com/kaime/dick 13 | cd dick 14 | sudo make install 15 | ``` 16 | 17 | ## Usage 18 | 19 | Run `dick --help` to show all command options. 20 | 21 | ## License 22 | 23 | [WTFPL](http://www.wtfpl.net/txt/copying/ " Do What the Fuck You Want to Public License.") 24 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # http://www.cyberciti.biz/tips/how-do-i-find-out-what-shell-im-using.html 4 | SHELL=`ps -hp $$ | awk '{print $5}'` 5 | 6 | ok() { 7 | echo -e " \e[32m√\e[0m" 8 | } 9 | 10 | fail() { 11 | echo -e " \e[31mFail!\e[0m" 12 | echo "$1" 13 | } 14 | 15 | test_output() { 16 | COMMAND="dick" 17 | if [[ "$1" != "" ]]; then 18 | COMMAND="$COMMAND $1" 19 | fi 20 | 21 | DICK="`dick $1`" 22 | EXPECTED="$2" 23 | 24 | echo -ne " - '\e[1m$COMMAND\e[0m' should output '\e[1m$EXPECTED\e[0m'" 25 | 26 | if [[ "$?" != 0 ]]; then 27 | fail "'$COMMAND' exit status was $?." 28 | exit 1 29 | fi 30 | 31 | if [[ $DICK != $EXPECTED ]]; then 32 | fail "Expected '$2', but got '$DICK'." 33 | exit 1 34 | fi 35 | ok 36 | } 37 | 38 | test_fails() { 39 | COMMAND="dick $1" 40 | 41 | echo -ne " - '\e[1m$COMMAND\e[0m' should fail" 42 | 43 | $COMMAND > /dev/null 44 | 45 | if [[ $? == "0" ]]; then 46 | fail "$COMMAND should have failed, but it didn't." 47 | exit 1 48 | fi 49 | 50 | ok 51 | } 52 | 53 | echo -e "Testing \e[1mdick\e[0m with \e[1m$SHELL\e[0m" 54 | 55 | test_output "" "8=====D" 56 | test_output "10" "8==========D" 57 | test_output "1" "8=D" 58 | test_output "--length=2 -s" "8==D ~~~" 59 | test_output "-l 2 -s=1" "8==D ~" 60 | test_output "4 -s 1" "8====D ~" 61 | test_output "-l --sperm=5" "8=====D ~~~~~" 62 | test_output "12 -s 10" "8============D ~~~~~~~~~~" 63 | test_output "-l 12 --sperm 0" "8============D" 64 | test_output "-v" "dick 0.2.0" 65 | test_output "--version" "dick 0.2.0" 66 | 67 | test_fails '-p' 68 | test_fails '-q' 69 | test_fails '--length --s' 70 | test_fails '--l' 71 | test_fails '--len' 72 | test_fails '0' 73 | test_fails 'bar' 74 | test_fails '-l 0' 75 | test_fails '-l none' 76 | test_fails '--length=0' 77 | test_fails '--length 00' 78 | test_fails '--length -1' 79 | test_fails '--length "0.1"' 80 | test_fails '--length ".01"' 81 | test_fails '--length -2.76' 82 | test_fails '-s -1' 83 | test_fails '--sperm 1.2' 84 | test_fails '--sperm=0.7' 85 | test_fails '--sperm=foo' 86 | -------------------------------------------------------------------------------- /dick.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION='0.2.0' 4 | 5 | is_numeric() { 6 | echo "$1" | grep -E "^[0-9]+$" 7 | } 8 | 9 | dick_usage() { 10 | echo " 11 | Usage: dick [] [options] 12 | 13 | Options: 14 | 15 | -l, --length [] Set dick length, in characters. Default is 5, a 16 | moderate dick length. It must be an integer, 17 | positive number (some dignity applies). 18 | -s, --sperm [] Display sperm stream with given , in 19 | characters. Default is 3. Omit this option or set 20 | it to 0 to output no sperm at all. 21 | -n Do not echo trailing newline. 22 | -v, --version Display dick version. 23 | -h, --help Display this help information. 24 | " 25 | } 26 | 27 | LENGTH=5 28 | SPERM=0 29 | LAST_OPT="-l" 30 | NEW_LINE=1 31 | 32 | while [ "$1" != "" ]; do 33 | OPT=`printf '%q' "$1" | awk -F= '{print $1}'` 34 | VAL=`printf '%q' "$1" | awk -F= '{print $2}'` 35 | 36 | case $OPT in 37 | -h | --help) 38 | dick_usage 39 | exit 40 | ;; 41 | -v | --version) 42 | echo "dick $VERSION" 43 | exit 44 | ;; 45 | -n) 46 | NEW_LINE="" 47 | ;; 48 | -s | --sperm) 49 | if [[ "$VAL" == "" ]]; then 50 | SPERM=3 51 | LAST_OPT="-s" 52 | else 53 | SPERM=$VAL 54 | fi 55 | ;; 56 | -l | --length) 57 | if [[ "$VAL" == "" ]]; then 58 | LAST_OPT="-l" 59 | else 60 | LENGTH=$VAL 61 | fi 62 | ;; 63 | *) 64 | case $LAST_OPT in 65 | -s) 66 | SPERM=$OPT 67 | ;; 68 | -l) 69 | LENGTH=$OPT 70 | ;; 71 | *) 72 | printf "Unexpected argument: '%q'\n" "$OPT" 73 | dick_usage 74 | exit 1 75 | ;; 76 | esac 77 | LAST_OPT="" 78 | esac 79 | 80 | shift 81 | 82 | done 83 | 84 | LENGTH_IS_NUMERIC=`is_numeric $LENGTH` 85 | 86 | if [[ $LENGTH_IS_NUMERIC != "" ]]; then 87 | 88 | if [[ "$LENGTH" -lt 1 ]]; then 89 | echo "Underestimated 'length' argument" 90 | dick_usage 91 | exit 1 92 | fi 93 | 94 | else 95 | echo "Bad 'length' argument: $LENGTH is not an integer, positive number" 96 | dick_usage 97 | exit 1 98 | fi 99 | 100 | SPERM_IS_NUMERIC=`is_numeric $SPERM` 101 | 102 | if [[ $SPERM_IS_NUMERIC == "" ]]; then 103 | echo "Bad 'sperm' length: $SPERM is not an integer, positive number" 104 | dick_usage 105 | exit 1 106 | fi 107 | 108 | DICK="8`seq 1 $LENGTH | sed 's/.*/=/' | tr -d '\n'`D" 109 | 110 | if [[ $SPERM != "0" ]]; then 111 | DICK="$DICK `seq 1 $SPERM | sed 's/.*/~/' | tr -d '\n'`" 112 | fi 113 | 114 | echo -n "$DICK" 115 | 116 | if [[ $NEW_LINE != "" ]]; then 117 | echo 118 | fi 119 | --------------------------------------------------------------------------------