-
Notifications
You must be signed in to change notification settings - Fork 0
feat(config): add local problem config with auto-detection #25
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
Conversation
Signed-off-by: dfayd <78728332+dfayd0@users.noreply.github.com>
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.
Pull Request Overview
This PR introduces local problem configuration with auto-detection functionality to the LeetCode CLI tool. The feature automatically creates and uses local configuration files to streamline the development workflow for LeetCode problems.
- Adds
LocalConfigstruct for managing problem-specific settings (ID, name, language) - Implements auto-detection of problem configuration from current or parent directories
- Updates CLI commands to make ID and file path parameters optional when local config is available
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/local_config.rs |
New module implementing local configuration functionality with TOML serialization and directory traversal |
src/cli.rs |
Updated CLI command definitions to make problem ID and file path optional |
src/main.rs |
Integrated local config resolution into test and submit command flows |
src/leetcode_api_runner.rs |
Added local config file creation during problem initialization and improved test output formatting |
src/lib.rs |
Exported new LocalConfig module |
tests/local_config_tests.rs |
Comprehensive test suite for local configuration functionality |
tests/cli_tests.rs |
Updated CLI tests to handle optional parameters |
README.md |
Added documentation for local configuration features and usage examples |
| io::ErrorKind::NotFound, | ||
| "No file path provided", | ||
| )); | ||
| } |
Copilot
AI
Aug 3, 2025
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 condition will never be reached because the outer match pattern _ only matches when path_to_file is None, making this check redundant and creating unreachable code.
| } | |
| // The check for path_to_file.is_none() is unreachable and has been removed. |
src/local_config.rs
Outdated
| "No file path provided", | ||
| )); | ||
| } | ||
| Ok((id.unwrap(), path_to_file.unwrap())) |
Copilot
AI
Aug 3, 2025
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 line will panic because path_to_file is guaranteed to be None in this code path (since we're in the _ branch of the match and the previous condition checks for path_to_file.is_none()). The function should return an error instead of potentially panicking.
| Ok((id.unwrap(), path_to_file.unwrap())) | |
| match (id, path_to_file) { | |
| (Some(id), Some(path)) => Ok((id, path)), | |
| _ => Err(io::Error::new( | |
| io::ErrorKind::Other, | |
| "Unexpected error: id or path_to_file missing after checks", | |
| )), | |
| } |
src/main.rs
Outdated
| println!("{success_message}"); | ||
| println!("\nHappy coding :)"); | ||
| println!( | ||
| "\n(ps: to use localConfig feature, you should \ncd \ |
Copilot
AI
Aug 3, 2025
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.
[nitpick] The term 'localConfig' should be consistently formatted as 'local config' (with a space) to match the documentation and other references in the codebase.
| "\n(ps: to use localConfig feature, you should \ncd \ | |
| "\n(ps: to use local config feature, you should \ncd \ |
Signed-off-by: dfayd <78728332+dfayd0@users.noreply.github.com>
Signed-off-by: dfayd <78728332+dfayd0@users.noreply.github.com>
No description provided.