Skip to content

Week 3 day 3#13

Open
Ngozistephen wants to merge 6 commits intoBloceducare:mainfrom
Ngozistephen:week-3-day-3
Open

Week 3 day 3#13
Ngozistephen wants to merge 6 commits intoBloceducare:mainfrom
Ngozistephen:week-3-day-3

Conversation

@Ngozistephen
Copy link

Task Submission PR

Student Info:

  • Registered Name: Stephen Ngozi
  • Week: week 3
  • Day: day 3

Task Details:

  • Task Name: Build a CLI Tool using the Rust Book
  • Task Description: Briefly describe the task completed.

Checklist Before Submitting:

  • [yes ] My code follows the repository folder structure.
  • [ yes] I have properly named my files and folders.
  • [ yes] I have documented my code where necessary.
  • [ yes ] I have tested my solution and ensured it works as expected.

Additional Comments:

If any, mention here.

Copilot AI review requested due to automatic review settings February 12, 2026 06:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR submits Rust coursework projects under submissions/, primarily a Week 3 Day 3 “minigrep”-style CLI (from The Rust Book), but it also includes additional Week 2 Day 3 and Day 5 projects.

Changes:

  • Added a Week 3 Day 3 CLI tool crate (stephenngozi-build-cli-project) with config parsing, file search (case-sensitive/insensitive), and unit tests.
  • Added a Week 2 Day 5 expense-tracker CLI project that persists expenses to a text file.
  • Added a Week 2 Day 3 user-input parsing example project.

Reviewed changes

Copilot reviewed 15 out of 18 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
submissions/week-3/day-3/stephenngozi-build-cli-project/src/main.rs CLI entrypoint: parse args, build config, run search
submissions/week-3/day-3/stephenngozi-build-cli-project/src/lib.rs Core search logic, Config, case-sensitivity toggle, unit tests
submissions/week-3/day-3/stephenngozi-build-cli-project/poem.txt Sample input file for the CLI tool
submissions/week-3/day-3/stephenngozi-build-cli-project/output.txt Captured sample output for a run
submissions/week-3/day-3/stephenngozi-build-cli-project/Cargo.toml Rust crate manifest
submissions/week-3/day-3/stephenngozi-build-cli-project/Cargo.lock Dependency lockfile
submissions/week-3/day-3/stephenngozi-build-cli-project/.gitignore Ignore Rust target/
submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/src/main.rs Expense tracker CLI UI loop (add/view/update/delete/save)
submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/src/tracker.rs ExpenseTracker storage + save-to-file
submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/src/expense.rs Expense and TransactionType definitions
submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/stephen_expences.txt Example saved output file
submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/Cargo.toml Rust crate manifest
submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/Cargo.lock Dependency lockfile
submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/.gitignore Ignore Rust target/
submissions/week-2/day-3/Stephen-Ngozi-User-Input/src/main.rs Simple stdin parsing + enum-based handling
submissions/week-2/day-3/Stephen-Ngozi-User-Input/Cargo.toml Rust crate manifest
submissions/week-2/day-3/Stephen-Ngozi-User-Input/Cargo.lock Dependency lockfile
submissions/week-2/day-3/Stephen-Ngozi-User-Input/.gitignore Ignore Rust target/

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

let args: Vec<String> = env::args().collect();

let config = Config::new(&args).unwrap_or_else(|err |{
eprintln!("Problem parsing argumemts: {}", err);
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in error message: "argumemts" should be "arguments" so users see a professional, searchable message.

Suggested change
eprintln!("Problem parsing argumemts: {}", err);
eprintln!("Problem parsing arguments: {}", err);

Copilot uses AI. Check for mistakes.
pub fn save_to_file(&self, filename: &str) {
let mut file = File::create(filename).expect("Could not create file");

for expense in self.values.values() {
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HashMap::values() iteration order is nondeterministic, so save_to_file can write expenses in a random order (the committed stephen_expences.txt already shows IDs out of order). Consider iterating in a stable order (e.g., collect/sort by id, or reuse view_all()).

Suggested change
for expense in self.values.values() {
for expense in self.view_all().iter() {

Copilot uses AI. Check for mistakes.
Comment on lines +108 to +112
if tracker.update(id, amount, tx_type){
println!("Expense Updated Successfu");

if let Some(expense) = tracker.values.get(&id) {
println!("ID: {}, Name: {}, Amount: Naria{:.2}, Type: {:?}",
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If tracker.update(...) returns false (ID not found), the user gets no feedback and the program silently continues. Add an else branch to print a not-found message (similar to delete).

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +40
tracker.save_to_file("stephen_expences.txt");
println!("Data saved to stephen_expences.txt");
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filename/message uses "expences" (typo). Consider renaming to "stephen_expenses.txt" and updating the saved output file accordingly so naming matches "expenses" throughout.

Suggested change
tracker.save_to_file("stephen_expences.txt");
println!("Data saved to stephen_expences.txt");
tracker.save_to_file("stephen_expenses.txt");
println!("Data saved to stephen_expenses.txt");

Copilot uses AI. Check for mistakes.
}
}
} else if input == "3" {
println!("Enter the ID of the Expence");
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in prompt: "Expence" should be "Expense".

Copilot uses AI. Check for mistakes.
let id: u8 = id_input.trim().parse().expect("Please enter a valid ID");

if tracker.delete(id){
println!(" Your Expence is Deleted ");
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in status message: "Expence" should be "Expense".

Suggested change
println!(" Your Expence is Deleted ");
println!(" Your Expense is Deleted ");

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +6

use std::io;
enum PowerStatus {
Off,
Sleep,
Reboot,
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says this is a Week 3 Day 3 submission, but this PR also adds Week 2 Day 3 / Day 5 projects. Per the repo submission guidance, week/day submissions should be kept scoped to the relevant folder; consider moving Week 2 additions into separate PR(s).

Copilot uses AI. Check for mistakes.
});


println!(" searching for {}", config.query);
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log line has a leading space in the format string, which makes output inconsistent (see output.txt) and harder to copy/paste. Consider removing the leading whitespace.

Suggested change
println!(" searching for {}", config.query);
println!("searching for {}", config.query);

Copilot uses AI. Check for mistakes.
Comment on lines +75 to +76
pub fn save_to_file(&self, filename: &str) {
let mut file = File::create(filename).expect("Could not create file");
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

save_to_file panics on file creation/write errors via expect. For a CLI, it’s better to return a Result (or bubble up an io::Result) so the caller can report the error without crashing.

Copilot uses AI. Check for mistakes.
Comment on lines +78 to +79
println!("ID: {} | Name: {} | Amount: Naria{:.2} | Type: {:?}",
expense.id, expense.name, expense.amount, expense.tx_type);
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in output label: "Naria" is likely meant to be "Naira".

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants