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

add execute & query view json function to cli cmd #232

Merged
merged 4 commits into from
Jul 19, 2024
Merged

Conversation

sh-cha
Copy link
Contributor

@sh-cha sh-cha commented Jul 19, 2024

  • add execute_json tx cmd
  • add view_json query cmd

@sh-cha sh-cha self-assigned this Jul 19, 2024
@sh-cha sh-cha requested a review from a team as a code owner July 19, 2024 03:22
Copy link

coderabbitai bot commented Jul 19, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

Walkthrough

The updates enhance the command structure in the CLI for querying and executing functions within a module. Key changes include renaming an existing query command for clarity, adding a new query command to return results in JSON format, and introducing new transaction commands that allow execution of entry functions and scripts using JSON-like arguments. These changes improve the usability and flexibility of the CLI commands for querying and executing functions.

Changes

File Summary of Changes
x/move/client/cli/query.go Renamed GetCmdQueryEntryFunction to GetCmdQueryViewFunction and added GetCmdQueryViewJSONFunction.
x/move/client/cli/tx.go Added ExecuteJSONCmd and ScriptJSONCmd to support JSON-like argument execution in transaction commands.
cmd/move/move.go Refactored moveEncodeCmd to process arguments using JSON strings from command flags instead of positional args.
x/move/client/cli/flags.go Updated descriptions in FlagSetArgs and FlagSetTypeArgs, and added FlagSetJSONArgs for JSON input handling.
x/move/client/cli/utils.go Replaced BcsSerializeArg with BCSEncode for improved argument processing; added functions for JSON array handling.
x/move/client/cli/utils_test.go Renamed and refactored test functions for clarity; added tests for new functionality in JSON handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Module

    User ->> CLI: Execute GetCmdQueryViewJSONFunction
    CLI ->> Module: Query View Function with JSON args
    Module -->> CLI: JSON results
    CLI -->> User: Display JSON results

    User ->> CLI: Execute ExecuteJSONCmd
    CLI ->> Module: Execute Entry Function with JSON args
    Module -->> CLI: Execution result
    CLI -->> User: Display execution result

    User ->> CLI: Execute ScriptJSONCmd
    CLI ->> Module: Execute Script with JSON args
    Module -->> CLI: Script execution result
    CLI -->> User: Display script result
Loading

Poem

In the code of Move, commands align,
Query and execute, functions divine.
JSON returns, with precision and grace,
Enhancing the CLI, at a rapid pace.
🐇 The rabbit hops, updates in view,
Bringing new features, just for you! 🌟


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 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

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

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 15.56291% with 255 lines in your changes missing coverage. Please review.

Project coverage is 39.95%. Comparing base (afa0faa) to head (c211719).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #232      +/-   ##
==========================================
- Coverage   40.24%   39.95%   -0.29%     
==========================================
  Files         259      259              
  Lines       24643    24816     +173     
==========================================
- Hits         9918     9916       -2     
- Misses      13191    13365     +174     
- Partials     1534     1535       +1     
Files Coverage Δ
x/move/client/cli/flags.go 0.00% <0.00%> (ø)
x/move/client/cli/utils.go 53.51% <65.27%> (-3.94%) ⬇️
x/move/client/cli/query.go 0.00% <0.00%> (ø)
x/move/client/cli/tx.go 0.00% <0.00%> (ø)

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.

Actionable comments posted: 16

Outside diff range, codebase verification and nitpick comments (3)
x/move/client/cli/tx.go (1)

204-235: Add tests for ExecuteJSONCmd function

The function ExecuteJSONCmd appears to be correctly implemented, but there is no evidence of associated test coverage. It is crucial to add unit tests to ensure the function behaves as expected and handles all edge cases.

  • Add unit tests for the ExecuteJSONCmd function in x/move/client/cli/tx.go.
Analysis chain

Verify the correctness and completeness of the function implementation.

Ensure that the function ExecuteJSONCmd is correctly implemented, follows best practices, and handles errors appropriately.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness and completeness of the function `ExecuteJSONCmd`.

# Test: Search for the function implementation and usage. Expect: Correct implementation and usage.
rg --type go 'func ExecuteJSONCmd'

Length of output: 115


Script:

#!/bin/bash
# Retrieve the full implementation of the function `ExecuteJSONCmd`
ast-grep --lang go --pattern $'func ExecuteJSONCmd($_) $_ {
  $$$
}' --json

# Search for where the function `ExecuteJSONCmd` is invoked or referenced in the codebase
rg 'ExecuteJSONCmd' -A 5

# Check for any associated tests with `ExecuteJSONCmd`
rg 'ExecuteJSONCmd' --type go -g '*_test.go' -A 5

Length of output: 6208


Script:

#!/bin/bash
# Search for any test files that might cover the functionality provided by `ExecuteJSONCmd` indirectly
rg 'execute_json' --type go -g '*_test.go' -A 5

Length of output: 47

Tools
GitHub Check: codecov/patch

[warning] 204-235: x/move/client/cli/tx.go#L204-L235
Added lines #L204 - L235 were not covered by tests

x/move/client/cli/query.go (2)

35-36: Ensure test coverage for the new command.

The command GetCmdQueryViewJSONFunction is correctly integrated into the queryCmd command group. However, there are no associated test cases found. Please add test cases to ensure the functionality of this new command.

  • Define test cases for GetCmdQueryViewJSONFunction in the appropriate test files.
Analysis chain

Verify the integration of the new command.

Ensure that the GetCmdQueryViewJSONFunction command is correctly integrated and functions as expected.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the new command `GetCmdQueryViewJSONFunction`.

# Test: Search for the new command usage. Expect: Integration with `GetQueryCmd`.
rg --type go 'GetCmdQueryViewJSONFunction'

Length of output: 199


Script:

#!/bin/bash
# Description: Verify the registration and test coverage of the new command `GetCmdQueryViewJSONFunction`.

# Test 1: Check if the new command is registered in the command group.
rg --type go 'AddCommand' -A 5

# Test 2: Check for test coverage of the new command.
rg --type go 'GetCmdQueryViewJSONFunction' --glob '*_test.go'

Length of output: 6868

Tools
GitHub Check: codecov/patch

[warning] 35-36: x/move/client/cli/query.go#L35-L36
Added lines #L35 - L36 were not covered by tests


366-397: Add test cases for GetCmdQueryViewJSONFunction.

It appears that there are no existing test cases covering the GetCmdQueryViewJSONFunction. To ensure its functionality is properly verified, please add relevant test cases.

  • Location: x/move/client/cli/query.go
Analysis chain

Verify the correctness and completeness of the function implementation.

Ensure that the function GetCmdQueryViewJSONFunction is correctly implemented, follows best practices, and handles errors appropriately.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness and completeness of the function `GetCmdQueryViewJSONFunction`.

# Test: Search for the function implementation and usage. Expect: Correct implementation and usage.
rg --type go 'func GetCmdQueryViewJSONFunction'

Length of output: 144


Script:

#!/bin/bash
# Extract the full implementation of the function `GetCmdQueryViewJSONFunction`.
ast-grep --lang go --pattern 'func GetCmdQueryViewJSONFunction($_) *cobra.Command { $$$ }'

# Search for test cases related to `GetCmdQueryViewJSONFunction`.
rg --type go 'GetCmdQueryViewJSONFunction'

Length of output: 5141


Script:

#!/bin/bash
# Search for test files that might cover the functionality of `GetCmdQueryViewJSONFunction`.
rg --type go 'GetCmdQueryViewJSONFunction' --glob '*_test.go'

# Search for test functions that might indirectly test `GetCmdQueryViewJSONFunction`.
rg --type go 'view_json'

Length of output: 235

Tools
GitHub Check: codecov/patch

[warning] 366-397: x/move/client/cli/query.go#L366-L397
Added lines #L366 - L397 were not covered by tests

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2b4b1ea and 2984a12.

Files selected for processing (2)
  • x/move/client/cli/query.go (3 hunks)
  • x/move/client/cli/tx.go (2 hunks)
Additional context used
GitHub Check: codecov/patch
x/move/client/cli/tx.go

[warning] 32-32: x/move/client/cli/tx.go#L32
Added line #L32 was not covered by tests


[warning] 204-235: x/move/client/cli/tx.go#L204-L235
Added lines #L204 - L235 were not covered by tests


[warning] 237-239: x/move/client/cli/tx.go#L237-L239
Added lines #L237 - L239 were not covered by tests


[warning] 241-248: x/move/client/cli/tx.go#L241-L248
Added lines #L241 - L248 were not covered by tests


[warning] 250-257: x/move/client/cli/tx.go#L250-L257
Added lines #L250 - L257 were not covered by tests


[warning] 259-262: x/move/client/cli/tx.go#L259-L262
Added lines #L259 - L262 were not covered by tests


[warning] 264-275: x/move/client/cli/tx.go#L264-L275
Added lines #L264 - L275 were not covered by tests


[warning] 277-277: x/move/client/cli/tx.go#L277
Added line #L277 was not covered by tests


[warning] 281-284: x/move/client/cli/tx.go#L281-L284
Added lines #L281 - L284 were not covered by tests

x/move/client/cli/query.go

[warning] 35-36: x/move/client/cli/query.go#L35-L36
Added lines #L35 - L36 were not covered by tests


[warning] 275-275: x/move/client/cli/query.go#L275
Added line #L275 was not covered by tests


[warning] 366-397: x/move/client/cli/query.go#L366-L397
Added lines #L366 - L397 were not covered by tests


[warning] 399-402: x/move/client/cli/query.go#L399-L402
Added lines #L399 - L402 were not covered by tests


[warning] 404-411: x/move/client/cli/query.go#L404-L411
Added lines #L404 - L411 were not covered by tests


[warning] 413-420: x/move/client/cli/query.go#L413-L420
Added lines #L413 - L420 were not covered by tests


[warning] 422-438: x/move/client/cli/query.go#L422-L438
Added lines #L422 - L438 were not covered by tests


[warning] 441-444: x/move/client/cli/query.go#L441-L444
Added lines #L441 - L444 were not covered by tests

Additional comments not posted (1)
x/move/client/cli/tx.go (1)

32-32: Verify the integration of the new command.

Ensure that the ExecuteJSONCmd command is correctly integrated and functions as expected.

Tools
GitHub Check: codecov/patch

[warning] 32-32: x/move/client/cli/tx.go#L32
Added line #L32 was not covered by tests

x/move/client/cli/tx.go Show resolved Hide resolved
x/move/client/cli/tx.go Outdated Show resolved Hide resolved
x/move/client/cli/tx.go Outdated Show resolved Hide resolved
x/move/client/cli/tx.go Outdated Show resolved Hide resolved
x/move/client/cli/tx.go Outdated Show resolved Hide resolved
x/move/client/cli/query.go Show resolved Hide resolved
x/move/client/cli/query.go Outdated Show resolved Hide resolved
x/move/client/cli/query.go Outdated Show resolved Hide resolved
x/move/client/cli/query.go Outdated Show resolved Hide resolved
x/move/client/cli/query.go Outdated Show resolved Hide resolved
Copy link
Contributor

@beer-1 beer-1 left a comment

Choose a reason for hiding this comment

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

LGTM

@beer-1 beer-1 merged commit 3434001 into main Jul 19, 2024
6 of 7 checks passed
@beer-1 beer-1 deleted the feat/execute_json_cli branch July 19, 2024 07:04
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