Skip to content
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

chore: force pre mine file path #6886

Closed

Conversation

SWvheerden
Copy link
Collaborator

@SWvheerden SWvheerden commented Mar 20, 2025

Description

remove the ability to ask for the file path in premine party start, and use a static file name/path

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced input file handling to automatically use a default file when no file path is provided, improving system stability and user experience.

Copy link
Contributor

coderabbitai bot commented Mar 20, 2025

Walkthrough

The changes update the command_runner function in the console wallet tool to improve input file path handling. Initially, the function sets the file path from the input arguments. If the file path is not provided, it prompts the user until a value is obtained. Afterwards, a match statement constructs the file path, defaulting to "step_1_session_info.json" if no input is given. This avoids a potential panic from unwrapping a None value.

Changes

File Change Summary
applications/minotari_console_wallet/.../commands.rs Updated command_runner: initializes input_file_path with args.input_file.clone(), uses a while loop for user input if None, and implements a match for fallback.

Sequence Diagram(s)

sequenceDiagram
    participant CR as CommandRunner
    participant User as User
    Note over CR: Start command_runner
    CR->>CR: Initialize input_file_path from args
    alt input_file_path is None
        CR->>User: Prompt for file path
        User-->>CR: Provide file path
    end
    CR->>CR: Match on input_file_path
    alt Valid file path provided
        CR->>CR: Create PathBuf from user input
    else No valid file path
        CR->>CR: Use default file "step_1_session_info.json"
    end
    Note over CR: Proceed with file operations
Loading

Suggested reviewers

  • stringhandler

Poem

I’m a bunny with a coding heart, 🐰
Hopping through the fields of logic and art.
Input paths now safely clear,
Default files bring a cheer!
Through the loops and match so bright,
Our code now bounds into the light.
Let’s celebrate this joyful flight!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa7e286 and 37106fa.

📒 Files selected for processing (1)
  • applications/minotari_console_wallet/src/automation/commands.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: Cucumber tests / FFI
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: cargo check with stable
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: ci
🔇 Additional comments (2)
applications/minotari_console_wallet/src/automation/commands.rs (2)

1040-1040: Initialization added for input_file_path

This change explicitly initializes input_file_path with the value from args.input_file.clone() before the while loop check, ensuring the variable is properly set even if the loop is never entered.


1051-1054: Improved error handling with default file path

The implementation now safely handles the case when no input file path is provided by using a match statement with a default value instead of directly unwrapping, which could panic. However, this only partially implements the PR objective to "remove the ability to specify a file path" since users can still provide custom paths through arguments or prompts.

For full alignment with the PR objective, consider removing the ability to specify a file path altogether:

-                let mut input_file_path = args.input_file.clone();
+                let input_file_path = None; // Ignore any provided file path

-                while input_file_path.is_none() {
-                    eprintln!("\nError: Missing input file path!\n");
-                    input_file_path = Some(
-                        InputPrompt::<String>::new()
-                            .with_prompt("Please enter the path to the input file")
-                            .interact()
-                            .unwrap(),
-                    );
-                }
-
-                let file_path = match input_file_path {
-                    Some(path) => PathBuf::from(path),
-                    None => PathBuf::from("step_1_session_info.json"),
-                };
+                let file_path = PathBuf::from("step_1_session_info.json");
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Test Results (CI)

    3 files    129 suites   43m 52s ⏱️
1 352 tests 1 352 ✅ 0 💤 0 ❌
4 054 runs  4 054 ✅ 0 💤 0 ❌

Results for commit 37106fa.

Copy link

Test Results (Integration tests)

36 tests  +36   36 ✅ +36   16m 23s ⏱️ + 16m 23s
11 suites +11    0 💤 ± 0 
 2 files   + 2    0 ❌ ± 0 

Results for commit 37106fa. ± Comparison against base commit aa7e286.

@SWvheerden SWvheerden closed this Mar 20, 2025
@SWvheerden SWvheerden deleted the sw_force_file_path branch March 20, 2025 11:39
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.

1 participant