Skip to content

Conversation

zees-dev
Copy link
Contributor

@zees-dev zees-dev commented May 6, 2025

Description

This PR adds JSON output support for forc-call CLI.

Additionally, it adds JSON support for tracing-subscriber in forc-tracing - with option to omit logs from other libraries (via regex).

  • JSON tracing-subscriber ignores colored output
  • Forc-call hooks into this tracing-subscriber (using Json variant) to output JSON response

Changelog

This pull request introduces enhancements to the forc-call plugin, focusing on improving output formatting, streamlining verbosity handling, and updating test cases to reflect these changes.
The most significant updates include the addition of a JSON output format, the removal of the Verbosity struct, and modifications to test cases to handle optional results.

Output Formatting Enhancements:

Verbosity Handling Simplification:

  • Removed the Verbosity struct and its associated methods. Verbosity is now directly represented as an integer (cmd.verbosity) for simplicity. (forc-plugins/forc-client/src/cmd/call.rs, [1]; forc-plugins/forc-client/src/op/call/call_function.rs, [2] [3] [4] [5]

Test Case Updates:

  • Modified test cases to handle optional results by calling .unwrap() on the result field where applicable. This ensures compatibility with changes to how results are processed. (forc-plugins/forc-client/src/op/call/call_function.rs, [1] through [2]

These changes improve the usability and maintainability of the forc-call plugin, making it more robust and user-friendly.

Note: This is a pre-requisite to resolve #7019; the output script in the JSON can be directly parsed into a tx.json file for forc-debug.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@zees-dev zees-dev requested review from a team as code owners May 6, 2025 05:09
@zees-dev zees-dev self-assigned this May 6, 2025
@zees-dev zees-dev temporarily deployed to fuel-sway-bot May 6, 2025 05:09 — with GitHub Actions Inactive
@zees-dev zees-dev added enhancement New feature or request forc labels May 6, 2025
@zees-dev zees-dev added logging Related to logging (tracing, stdout, stderr, log-files) dev-experience Anything to do with the developer experience forc-call Everything related to the `forc-call` plugin in `forc-client` package team:tooling Tooling Team labels May 6, 2025
Copy link

codspeed-hq bot commented May 6, 2025

CodSpeed Performance Report

Merging #7156 will not alter performance

Comparing feat/forc-call-json-output (bcd7c55) with master (bd38136)

Summary

✅ 22 untouched benchmarks

@zees-dev zees-dev temporarily deployed to fuel-sway-bot May 6, 2025 23:27 — with GitHub Actions Inactive
@zees-dev zees-dev temporarily deployed to fuel-sway-bot May 6, 2025 23:57 — with GitHub Actions Inactive
@JoshuaBatty JoshuaBatty requested a review from a team May 8, 2025 02:57
@zees-dev zees-dev temporarily deployed to fuel-sway-bot May 9, 2025 03:31 — with GitHub Actions Inactive
@zees-dev zees-dev merged commit dffa29c into master May 9, 2025
46 checks passed
@zees-dev zees-dev deleted the feat/forc-call-json-output branch May 9, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-experience Anything to do with the developer experience enhancement New feature or request forc forc-call Everything related to the `forc-call` plugin in `forc-client` package logging Related to logging (tracing, stdout, stderr, log-files) team:tooling Tooling Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Have forc create a tx.json file so it can be used by forc-debug
3 participants