Skip to content

Commit

Permalink
Add cow: cowbees
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrof-ciandt committed Sep 4, 2020
1 parent 4813789 commit f922914
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
## Why
Cowsay was originally written in Perl by [Tony Monroe](https://github.com/tnalpgge/rank-amateur-cowsay). This project is a translation in the [Swift language](https://swift.org/) based on the original idea.
Created for a similar purpose as it's author:
> A simple and silly project for learning how to use Swift, as a executable (cli), as well as general amusement around this ecosystem.
> A simple and silly project for learning how to use Swift, as a executable [cli](https://en.wikipedia.org/wiki/Command-line_interface), as well as general amusement around this ecosystem.
## Install
```sh
Expand All @@ -32,7 +32,7 @@ cp -f .build/release/CommandLineTool /usr/local/bin/commandlinetool
swift run cowsay Swift rocks
```

## Extended usage options
## Options
```sh
swift run cowsay -h

Expand Down
7 changes: 3 additions & 4 deletions Sources/cowsay/CowNames.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//
// CowNames.swift
//
//
// Created by Leandro Nunes Fantinatto on 03/09/20.
//

Expand All @@ -11,10 +9,11 @@ typealias CowName = String

enum CowNames: CowName {
case example
case cowffee
case cowffee, cowbees

static let all: [Cow] = [
Example(name: CowNames.example.rawValue),
Cowffee(name: CowNames.cowffee.rawValue)
Cowffee(name: CowNames.cowffee.rawValue),
Cowbees(name: CowNames.cowbees.rawValue),
]
}
4 changes: 1 addition & 3 deletions Sources/cowsay/CowProtocol.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//
// CowNames.swift
//
//
// CowProtocol.swift
// Created by Leandro Nunes Fantinatto on 03/09/20.
//

Expand Down
31 changes: 31 additions & 0 deletions Sources/cowsay/Cows/Cowbees.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Cowbees.swift
// Created by Leandro Nunes Fantinatto on 03/09/20.
// Ref: http://www.asciiworld.com/-Bees-.html
//

import Foundation

struct Cowbees: Cow {

let name: String

var eyes: String = ""
var tongue: String = ""
let image = """
$paddingTop
< $thoughts >
$paddingBottom
\\
\\ \\ _ /
/ $eyes \\ _ z z
\\~~~ /// \\ z z
/--\\// )) z z
()==/()==\\__./ B z z z z z z
()=( ()= ) z z
\\____/ z z z
||||
(/ \\)
"""
}
8 changes: 3 additions & 5 deletions Sources/cowsay/Cows/Cowffee.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//
// Cowffee.swift
//
//
// Created by Leandro Nunes Fantinatto on 03/09/20.
//

Expand All @@ -21,9 +19,9 @@ struct Cowffee: Cow {
\\ } } {
{ { } }
} } { {
{ } { } }
( }{ }{ { )
.-{ } }-.
{ } { } }
( }{ } { { )
.-{ } }-.
( ( } { } { } )
|`-.._____..-'|
| ;--.
Expand Down
4 changes: 1 addition & 3 deletions Sources/cowsay/Cows/Example.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//
// CowNames.swift
//
//
// Example.swift
// Created by Leandro Nunes Fantinatto on 03/09/20.
//

Expand Down
8 changes: 3 additions & 5 deletions Sources/cowsay/Cowsay.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//
// CowNames.swift
//
//
// Cowsay.swift
// Created by Leandro Nunes Fantinatto on 03/09/20.
//

Expand All @@ -10,7 +8,7 @@ import Foundation

final class Cowsay {

static func createCow(
static func create(
named: String,
withEyes eyes: String,
andTongue tongue: String
Expand All @@ -26,7 +24,7 @@ final class Cowsay {
return cow
}

static private func getCow(named: String) -> Cow? {
static func getCow(named: String) -> Cow? {
CowNames.all.first { $0.name == named }
}
}
6 changes: 2 additions & 4 deletions Sources/cowsay/main.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//
// CowNames.swift
//
//
// main.swift
// Created by Leandro Nunes Fantinatto on 03/09/20.
//

Expand Down Expand Up @@ -37,7 +35,7 @@ struct Cli: ParsableCommand {
// MARK: - Init

mutating func run() throws {
let cow = try Cowsay.createCow(named: name, withEyes: eyes, andTongue: tongue)
let cow = try Cowsay.create(named: name, withEyes: eyes, andTongue: tongue)
print(cow.say(it: message.joined(separator: " ")))
}
}
Expand Down

0 comments on commit f922914

Please sign in to comment.