-
-
Notifications
You must be signed in to change notification settings - Fork 42
cowsay CLI project with scaffolding #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Cowsay | ||
|
||
Do you remember [Cowsay](https://github.com/CodeYourFuture/JavaScript-Core-1-Challenges)? We learned about node packages and made a cow say stuff. Now, we know more about programming, let's figure out how to make a cow say things in Node by ourselves. | ||
|
||
## Project | ||
|
||
For this project we don't need a package, a library or lots of options. Let's just get our own cow printing out and saying whatever we write in the command line. What would be helpful? I think we need to: | ||
|
||
- [Accept an argument](https://nodejs.dev/learn/nodejs-accept-arguments-from-the-command-line) from the command line. | ||
- Output to the command line. You've already done this with console.log. | ||
- Make an ASCII cow. | ||
- Write a function that puts the string into the cow's speech bubble. | ||
|
||
Write your solution in the file solution1.js and test it by running your program in the command line. How will you handle it when no argument is given? How will you make the picture of a cow? | ||
|
||
### Iterating | ||
|
||
We could make our program more accessible by adding a command line interface that prompts us to write in the cow's words. What tools can we use? I think we could use: | ||
|
||
- A command line interface. I'll start you off by letting you know that there is a built in CLI called [readline](https://nodejs.dev/learn/accept-input-from-the-command-line-in-nodejs). | ||
- Our ASCII cow again. | ||
- And our cow function. | ||
|
||
Write your solution in a file called solution2.js and test it by running your program in the command line. Use a prompt to ask for your cow saying. | ||
|
||
Compare your approach to the sample solutions (you can unlock next week). Your solution might be different and that's ok. If you can print a cow and you can make it say different things, you solved it. | ||
|
||
A slightly simpler ASCII cow that might help if you hit formatting issues. | ||
|
||
``` | ||
/ | ||
/ | ||
^__^ / | ||
(oo)'_______ | ||
(__) )-~ | ||
||----w | | ||
|| || | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// ================= | ||
// Stripped down cowsayer CLI, | ||
// no libraries | ||
// https://nodejs.dev/learn/nodejs-accept-arguments-from-the-command-line | ||
// ================= | ||
|
||
// 1. Accept arguments | ||
|
||
// how will you accept arguments? | ||
|
||
// 2. Make supplies for our speech bubble | ||
|
||
let topLine = '_'; | ||
let bottomLine = '-'; | ||
let saying = ''; | ||
|
||
// 3. Make a cow that takes a string | ||
|
||
function cowsay(saying) { | ||
// how will you make the speech bubble contain the text? | ||
|
||
// where will the cow picture go? | ||
|
||
// how will you account for the parameter being empty? | ||
|
||
} | ||
|
||
//4. Pipe argument into cowsay function and return a cow | ||
|
||
// how will you log this to the console? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// ================= | ||
// Stripped down cowsayer CLI, | ||
// no libraries or arguments | ||
// https://nodejs.dev/learn/accept-input-from-the-command-line-in-nodejs | ||
// ================= | ||
|
||
// 1. Make a command line interface. | ||
|
||
// 2. Make supplies for our speech bubble | ||
|
||
// 3. Make a cow that takes a string | ||
|
||
const cow = (saying) => { | ||
// how did you make the cow before? | ||
} | ||
|
||
// 4. Use readline to get a string from the terminal | ||
// (with a prompt so it's clearer what we want) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you trying to nudge them towards removing the argument, or prompting if no argument was given? I feel like being slightly more explicit about that could be useful (this doesn't feel like super useful ambiguity to have them resolve :))