Skip to content

Commit

Permalink
Update with more characters. Merge in piuccio/cowsay master. (scottte…
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttesler authored Oct 13, 2017
1 parent e235f31 commit 4ff1bbb
Show file tree
Hide file tree
Showing 27 changed files with 3,756 additions and 120 deletions.
17 changes: 4 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,7 @@ build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz
.*
!.gitignore
!.travis.yml
build
3 changes: 2 additions & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
6.7.0
8.7.0

5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- 4
- 6
sudo: false
60 changes: 58 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
::::::::\ `--' /::::::::
````

yodasay is a (currently non-configurable) talking yoda, based on cowsay, originally written in Perl by [Tony Monroe](http://www.nog.net/~tony/) and then re-written in Node.js by [Fabio Crisci](https://github.com/piuccio).
yodasay is a configurable talking yoda, originally written in Perl by [Tony Monroe](https://github.com/tnalpgge/rank-amateur-cowsay) and then re-written in Node.js by [Fabio Crisci](https://github.com/piuccio).

This project is a fork of https://github.com/piuccio/cowsay.
The Yoda ASCII art was taken from [Christopher Johnson](http://www.chris.com/ascii/index.php?art=movies/star%20wars)'s website.
Expand All @@ -30,7 +30,24 @@ or

yodathink Node.js is cool

It acts (well, it will eventually) in the same way as cowsay, so consult `cowsay(1)` or run `cowsay -h`
It acts in the same way as cowsay, so consult `yodasay(1)` or run `yodasay -h`

````
________
< indeed >
--------
\
\
.::!!!!!!!:.
.!!!!!:. .:!!!!!!!!!!!!
~~~~!!!!!!. .:!!!!!!!!!UWWW$$$
:$$NWX!!: .:!!!!!!XUWW$$$$$$$$$P
$$$$$##WX!: .<!!!!UW$$$$" $$$$$$$$#
$$$$$ $$$UX :!!UW$$$$$$$$$ 4$$$$$*
^$$$B $$$$\ $$$$$$$$$$$$ d$$R"
"*$bd$$$$ '*$$$$$$$$$$$o+#"
"""" """""""
````

## Usage as a module

Expand All @@ -47,3 +64,42 @@ yodasay can be used as any other npm dependency
## Pipe from standard input

echo please repeat | yodasay

## Usage in the browser

yodasay works in your browser too with rollup / webpack / browserify / you name it.

```js
import { say } from 'yodasay';

console.log(say({ text: 'meditating in the browser' }));
```

You can customize the character by importing the relevant one

```js
import { think, R2D2 } from 'yodasay';

console.log(think({
text: 'meditating in the browser',
cow: R2D2,
eyes: 'pp',
tongue: ';;',
}));
```

All characters are included in the bundle, but you can use rollup / webpack tree-shake feature to reduce the final bundle size.

### Browser options

```js
say({
text: 'hello',
cow: '', // Template for a character, get inspiration from `./cows`
eyes: 'oo', // Select the appearance of the character's eyes, equivalent to yodasay -e
tongue: 'L|', // The tongue is configurable similarly to the eyes through -T and tongue_string, equivalent to yodasay -T
wrap: false, // If it is specified, the given message will not be word-wrapped. equivalent to yodasay -n
wrapLength: 40, // Specifies roughly where the message should be wrapped. equivalent to yodasay -W
mode: 'b', // One of "b", "d", "g", "p", "s", "t", "w", "y"
});
```
42 changes: 42 additions & 0 deletions browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import baloon from "./lib/balloon";
import replacer from "./lib/replacer";
import faces from "./lib/faces";

import DEFAULT_COW from './cows/default.cow';

export { default as R2D2 } from './cows/R2D2.cow';
export { default as DEFAULT } from './cows/default.cow';

function converToCliOptions(browserOptions) {
const cliOptions = {
e: browserOptions.eyes || 'oo',
T: browserOptions.tongue || ' ',
n: browserOptions.wrap,
W: browserOptions.wrapLength || 40,
text: browserOptions.text || '',
_: browserOptions.text || [],
f: browserOptions.cow,
};
if (browserOptions.mode) {
// converts mode: 'b' to b: true
cliOptions[browserOptions.mode] = true;
}
return cliOptions;
}

function doIt (options, sayAloud) {
const cow = options.f || DEFAULT_COW;
const face = faces(options);
face.thoughts = sayAloud ? "\\" : "o";

const action = sayAloud ? "say" : "think";
return baloon[action](options.text || options._.join(" "), options.n ? null : options.W) + "\n" + replacer(cow, face);
}

export function say(browserOptions) {
return doIt(converToCliOptions(browserOptions), true);
}

export function think(browserOptions) {
return doIt(converToCliOptions(browserOptions), false);
}
13 changes: 0 additions & 13 deletions characters/yoda.character

This file was deleted.

68 changes: 55 additions & 13 deletions cli.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,66 @@
#!/usr/bin/env node
var argv = require("optimist")
.usage("Usage: $0 [-h] [-l] [-n] [-W column] text\n\n" +
"If any command-line arguments are left over after all switches have been processed, they become the character's message.\n\n" +
"If the program is invoked as yodathink then the character will think its message instead of saying it.")
.describe({
"h" : "Display this help message",
"n" : "If it is specified, the given message will not be word-wrapped.",
"W" : "Specifies roughly where the message should be wrapped. The default is equivalent to -W 40 i.e. wrap words at or before the 40th column.",
"l" : "List all characters included in this package."
})
.argv;
.usage("Usage: $0 [-e eye_string] [-f cowfile] [-h] [-l] [-n] [-T tongue_string] [-W column] [-bdgpstwy] text\n\n" +

" _________________ ____ __________\n" +
". . / | / \\ . | \\ \n" +
" . / ______ _____| . / \\ | ___ | . .\n" +
" \\ \\ | | / /\\ \\ | |___> | \n" +
" . \\ \\ | | / /__\\ \\ . | _/ .\n" +
". ________> | | | . / \\ | |\\ \\_______ .\n" +
" | / | | / ______ \\ | | \\ |\n" +
" |___________/ |___| /____/ \\____\ |___| \\__________| .\n" +
" . ____ __ . _____ ____ . __________ . _________\n" +
" \\ \\ / \\ / / / \\ | \\ / | .\n" +
" \\ \\/ \\/ / / \\ | ___ | / ______| .\n" +
" \\ / / /\\ \\ . | |___> | \\ \\ \n" +
" . \\ / / /__\\ \\ | _/. \\ \\ \n" +
" \\ /\\ / / \\ | |\\ \\______> | .\n" +
" \\ / \\ / / ______ \\ | | \\ / .\n" +
". . \\/ \\/ /____/ \\____\\ |___| \\____________/\n\n" +
"If the program is invoked as `yodathink` then the character will think its message instead of saying it.")
.options({
"e" : {
default : "oo"
},
"T" : {
default : " "
},
"W" : {
default : 40
},
"f" : {
default : "default"
}
})
.describe({
"b" : "Mode: Borg",
"d" : "Mode: Dead",
"g" : "Mode: Greedy",
"p" : "Mode: Paranoia",
"s" : "Mode: Stoned",
"t" : "Mode: Tired",
"w" : "Mode: Wired",
"y" : "Mode: Youthful",
"e" : "Select the appearance of the character's eyes.",
"T" : "The tongue is configurable similarly to the eyes through -T and tongue_string.",
"h" : "Display this help message",
"n" : "If it is specified, the given message will not be word-wrapped.",
"W" : "Specifies roughly where the message should be wrapped. The default is equivalent to -W 40 i.e. wrap words at or before the 40th column.",
"f" : "Specifies a character picture file (''cowfile'') to use. It can be either a path to a character file or the name of one of characters included in the package.",
"l" : "List all cowfiles included in this package."
})
.boolean(["b", "d", "g", "p", "s", "t", "w", "y", "n", "h", "l"])
.argv;

if (argv.l) {
listCharacters();
listCows();
} else if (argv.h) {
showHelp();
} else if (argv._.length) {
say();
} else {
require("get-stdin")(function (data) {
require("get-stdin")().then(function (data) {
if (data) {
argv._ = [data];
say();
Expand All @@ -36,7 +78,7 @@ function say () {
console.log(think ? module.think(argv) : module.say(argv));
}

function listCharacters () {
function listCows () {
require("./index").list(function(err, list) {
if (err) throw new Error(err);
console.log(list.join(" "));
Expand Down
19 changes: 19 additions & 0 deletions cows/R2D2.cow
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
##
## R2D2.
##
$the_cow = <<EOC;
$thoughts
$thoughts
_--~~--_
/~/_| |_\~\
|____________|
|[][][][][][]|:= .
__| __ |__ \ ' .
| ||. | == | | \ ' .
(| ||__| == | |) \ < >
| |[] [] == | | \ \|/
| |____________| | \ |
/__\ /__\ \ / \
~~ ~~

EOC
29 changes: 29 additions & 0 deletions cows/boba.cow
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
##
## Boba Fett.
##
$the_cow = <<EOC;
$thoughts
$thoughts
|~
|.---.
.'_____`. /\
|~xxxxx~| ||
|_ # _| ||
.------`-#-'-----.
(___|\_________/|_.`.
/ | _________ | | |
/ |/ _|_ \| | |
/ /X| __|__ |/ `.|
( --< \\/ _\//|_ |`.
`. ~----.-~=====,:=======
~-._____/___:__(``/| |
| | XX|~ | |
\__/======| /| `.|
|_\|\ /|/_| )
|_ \__/ _| .-'
| \ .'||`. / |(_|
| ||.'`.|| | )
| `'| |`' | /
| | | |\/

EOC
28 changes: 28 additions & 0 deletions cows/chewbacca.cow
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
##
## Chewbacca.
##
$the_cow = <<EOC;
$thoughts
$thoughts
,.------;:~~:-.
/:.\`;;|||;:/;;:\
:')\`:\||::/.-_':/)
`:`\\\ ;'||'.''/,.:\
==`;.:`|;::/'/./';;=
:-/-%%% | |%%%;;_- _:
=// %wm)..(mw%`_ :`:\
;;--', /88\ -,- :-~~|
-;~~::'`~^~:`::`/`-=:)
(;':)%%%' `%%%.`:``:)\
(\ %%%/dV##Vb`%%%%:`-.
|);/( ;~~~~ :)\`;;.``\
//\'/,/|;;|:(: |.|\;|\
/) |(/ | / \|\\`( )- `
;):):)/.):|/) (`:`\\`-`
;%/ //;/(\`.':| ::`\\;`
;/~( \|./;)|.|):;\. \\-
/',:\//) ||`.|| (:\)):%
,|/;/(%;.||| (|(\:- ; :
_%__%:__;_:`_;_:_.\%_`_

EOC
14 changes: 14 additions & 0 deletions cows/default.cow
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
##
## Yoda.
##
$the_cow = <<EOC;
$thoughts
$thoughts
.--.
\`--._,'.::.`._.--'/
. ` __::__ ' .
-:.`'..`'.:-
\ `--' /
----

EOC
28 changes: 28 additions & 0 deletions cows/han.cow
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
##
## Han Solo.
##
$the_cow = <<EOC;
$thoughts
$thoughts
.x%%%%%%x.
,%%%%%%%%%%%
,%%%' )' \%
,%x%) __ _ Y
:%%% ~=-. <=~|
:%%::. .:,\ |
`;%:`\. `-' .'
``x`. -===-;
/ `:`.__.;
.d8b. :: ..`.
d88888b. ' /8
d888888888b. ( 8b /
~ ~`888888b `8b /:
' ' `888888 `8. _ /:/
' )88888b 8b |):X
~ - |888888 `8b/:/:\
|888888 88\/~~;
(888888b 88| /
\ \888888 8-: /
_\_______\88888_.'___\__/

EOC
22 changes: 22 additions & 0 deletions cows/joshuabell.cow
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
##
## Joshua Bell.
##
$the_cow = <<EOC;
$thoughts
$thoughts
/___/
| _______
| ,-' `-,
| / \
|`| __/| |\__ |
|]|_______________|
| ||___ ___||
| | `-. .-' |
\`-, | | ,-'
| \ | | / |
| \ | | / |
| | | | | |
|,_ | | | | _,|
`-|_|-|_|-'

EOC
Loading

0 comments on commit 4ff1bbb

Please sign in to comment.