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

feat: add CLI commands for RPC URL and block number #1194

Merged
merged 5 commits into from
Feb 29, 2024

Conversation

penandlim
Copy link
Contributor

@penandlim penandlim commented Feb 28, 2024

Implemented CLI arguments --rpc-url and --rpc-block to allow overriding the corresponding environment variables.

The precedence for settings is now: Command-Line Arguments > Environment Variables > Configuration Defaults.

Closes #1193

Summary by CodeRabbit

  • New Features
    • Introduced new command-line options for specifying RPC URL and block number, enhancing user control over configuration settings.
  • Enhancements
    • Improved configuration override mechanism to prioritize command-line inputs over environment variables, offering users more flexibility in setting preferences.

@CLAassistant
Copy link

CLAassistant commented Feb 28, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

coderabbitai bot commented Feb 28, 2024

Walkthrough

The latest update enhances the application by integrating new command-line options for specifying RPC URLs and block numbers. This enhancement not only broadens the configurability through the command line but also ensures that these settings can default to environment variables if not explicitly provided, offering a flexible and user-friendly approach to configuration management.

Changes

File(s) Change Summary
src/Main.hs Introduced Word64 to the import list from Data.Word, added cliRpcUrl and cliRpcBlock options to the Options data type, and updated the options function to parse these new arguments. The overrideConfig function was also modified to prioritize command-line values over environment variables for rpcUrl and rpcBlock.

Assessment against linked issues

Objective Addressed Explanation
Add --rpc-url and --rpc-block CLI commands

"In the realm of code where logic plays,
A rabbit hopped through the maze of days.
With each leap and bound, new options found,
🌐 URLs and blocks, in command lines wound.
🚀 To the moon, our settings now align,
With environment fallbacks, oh so fine.
Rejoice in the updates, fresh and bright,
For our code now runs with newfound might."
🐰✨

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e72975c and 38ebde2.
Files selected for processing (1)
  • src/Main.hs (4 hunks)
Additional comments: 4
src/Main.hs (4)
  • 19-19: The addition of Word64 to the import list from Data.Word is necessary for supporting the new --rpc-block CLI argument, which expects a block number of type Word64. This change is appropriate and ensures that the necessary types are available for handling the new functionality.
  • 136-137: The addition of cliRpcUrl and cliRpcBlock to the Options data type introduces new fields to store the values of the --rpc-url and --rpc-block CLI arguments, respectively. This change is crucial for enabling the new functionality and allows these values to be passed through the application. The choice of Maybe Text for cliRpcUrl and Maybe Word64 for cliRpcBlock is appropriate, as it allows for the absence of these arguments, aligning with the described precedence of configuration settings.
  • 197-202: The update to the options parser function to handle the --rpc-url and --rpc-block arguments is implemented correctly. The use of optional and the appropriate types (str for --rpc-url and auto for --rpc-block) ensures that these arguments are optional and parsed correctly. The help messages provided are clear and informative, guiding the user on how to use these new options.
  • 217-218: The modifications to the overrideConfig function to prioritize CLI-provided values for rpcUrl and rpcBlock over environment variables and default configurations are implemented as described. The use of the <|> operator to select the first non-Nothing value among the CLI argument, environment variable, and existing configuration ensures that the precedence order is respected. This change effectively integrates the new CLI arguments into the application's configuration logic.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 38ebde2 and 63cb249.
Files selected for processing (1)
  • src/Main.hs (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/Main.hs

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 38ebde2 and 3381469.
Files selected for processing (1)
  • src/Main.hs (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/Main.hs

Copy link
Member

@arcz arcz left a comment

Choose a reason for hiding this comment

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

Thanks for contributing! There is a little mistake in your solution but it's easily fixable.

src/Main.hs Outdated
@@ -206,8 +214,8 @@ versionOption = infoOption

overrideConfig :: EConfig -> Options -> IO EConfig
overrideConfig config Options{..} = do
rpcUrl <- Onchain.rpcUrlEnv
rpcBlock <- Onchain.rpcBlockEnv
rpcUrl <- (pure cliRpcUrl) <|> Onchain.rpcUrlEnv
Copy link
Member

Choose a reason for hiding this comment

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

This unfortunately won't work since <|> here operates on IO, not on Maybe. Can you rename rpcUrl to envRpcUrl (same for block) and change this instead: rpcUrl = cliRpcUrl <|> envRpcUrl <|> config.rpcUrl

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Thanks for the quick review!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3381469 and a562a06.
Files selected for processing (1)
  • src/Main.hs (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/Main.hs

Copy link
Member

@arcz arcz left a comment

Choose a reason for hiding this comment

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

LGTM!

@arcz arcz merged commit 8339bad into crytic:master Feb 29, 2024
17 of 18 checks passed
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.

Add --rpc-url and --rpc-block CLI commands
3 participants