-
-
Notifications
You must be signed in to change notification settings - Fork 42
London | 25-SDC-July | Franklin Kamela | Sprint 3 | Feature/Implement Shell Tools #135
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
base: main
Are you sure you want to change the base?
London | 25-SDC-July | Franklin Kamela | Sprint 3 | Feature/Implement Shell Tools #135
Conversation
LonMcGregor
left a comment
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.
Hi,
Remember to update the template when you open a new PR on github - you have left the default text there, so I don't know what the goal of this PR is.
You have made a good start on these tasks. I've left some comments for how you could improve them further.
implement-shell-tools/cat/my_cat.js
Outdated
| showLineNumb = false; | ||
| showNoBlankNumb = true; | ||
| }else { | ||
| file = arg; |
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.
What happens if I want to pass multiple files in here? For example, using the * wildcard which expands to multiple files in the shell.
Your solution in wc seems a better approach
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.
This seems to be fixed now - well done
implement-shell-tools/cat/my_cat.js
Outdated
| }).join('\n'); | ||
| } | ||
|
|
||
| console.log (content) |
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.
Be careful of formatting your code the same way. Can you see why this line is inconsistent with the rest of the file?
implement-shell-tools/ls/my_ls.js
Outdated
| args.forEach(arg => { | ||
| if (arg === '-a') { | ||
| showAll = true; | ||
| } else if (arg !== '-1') { |
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.
This approach might cause problems in two cases:
- What if the user does not want each output per line and wants it all on one line (like the original
ls) app? - Assuming anything else is a directory might make it more difficult to add new options in the future.
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.
This is fixed now - great
implement-shell-tools/wc/my_wc.js
Outdated
| const totalBytes = validCounts.reduce((sum, c) => sum + c.bytes, 0); | ||
|
|
||
| let totalOutput = ''; | ||
| if (showLines) totalOutput += `${totalLines} `; |
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.
There is some duplication here when you are printing totals and when you print single file output. Can you think of how to reduce this?
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.
Great work
implement-shell-tools/wc/my_wc.js
Outdated
| } | ||
|
|
||
| async function main() { | ||
| const counts = await Promise.all(files.map(countFile)); |
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.
This is a very minor point, but when doing map we expect it to return a new array that is different from the input array. Instead of .map can you think of another array function that would make more sense to use here?
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.
Good solution
|
hi @LonMcGregor, i have now amended this cat, ls, and wc to address review. |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. |
1 similar comment
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. |
LonMcGregor
left a comment
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.
Good work on updating these. The only thing left to work in is making sure that your cat can handle numbering multiple files
implement-shell-tools/cat/my_cat.js
Outdated
| showLineNumb = false; | ||
| showNoBlankNumb = true; | ||
| }else { | ||
| file = arg; |
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.
This seems to be fixed now - well done
implement-shell-tools/cat/my_cat.js
Outdated
| const lines = content.split('\n'); | ||
|
|
||
| if (showNoBlankNumb) { // Number only non-blank lines | ||
| let counter = 1; |
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.
Try testing your updated solution with the numbering options on with multiple files now your app supports it. How would you expect it to work? If you compare your solution to the original cat, can you see a discrepancy?
implement-shell-tools/ls/my_ls.js
Outdated
| args.forEach(arg => { | ||
| if (arg === '-a') { | ||
| showAll = true; | ||
| } else if (arg !== '-1') { |
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.
This is fixed now - great
implement-shell-tools/wc/my_wc.js
Outdated
| } | ||
|
|
||
| async function main() { | ||
| const counts = await Promise.all(files.map(countFile)); |
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.
Good solution
implement-shell-tools/wc/my_wc.js
Outdated
| const totalBytes = validCounts.reduce((sum, c) => sum + c.bytes, 0); | ||
|
|
||
| let totalOutput = ''; | ||
| if (showLines) totalOutput += `${totalLines} `; |
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.
Great work
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. |
1 similar comment
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. |
|
hi @LonMcGregor, amended my_cat.js to address review. |
|
In my_cat.js why do you use two different counter variables? Is there a circumstance where you can be numbering both blank and non-blank lines at once where you would need to count these separately? |
|
hi @LonMcGregor, i don't actually need 2 different counter variables as |
|
@Fradoka It is worth considering the trade-offs here. Two counters would let you differentiate it, and maybe in a more complex app you might want to add features that require it, so it's good you considered this. But here it probably isn't necessary. Good work on this sprint task, it's done now! |
Learners, PR Template
Self checklist
Changelist
Questions