Skip to content

Print output in json format when using global --json flag#274

Draft
vbmade2000 wants to merge 3 commits into
reductstore:mainfrom
vbmade2000:mvora/254-add-json-output-for-bucket-commands
Draft

Print output in json format when using global --json flag#274
vbmade2000 wants to merge 3 commits into
reductstore:mainfrom
vbmade2000:mvora/254-add-json-output-for-bucket-commands

Conversation

@vbmade2000

Copy link
Copy Markdown
Contributor

Closes #254

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • CHANGELOG.md has been updated (for bug fixes / features / docs)

What kind of change does this PR introduce?

(Bug fix, feature, docs update, ...)

What was changed?

(Describe the changes)

Related issues

(Add links to related issues)

Does this PR introduce a breaking change?

(What changes might users need to make in their application due to this PR?)

Other information:

Signed-off-by: Malhar Vora <mlvora.2010@gmail.com>
@vbmade2000

Copy link
Copy Markdown
Contributor Author

@atimin The PR is still in WIP. Let me know your thoughts on approach taken in this PR.

Comment thread src/main.rs Outdated
// Do not output json if the command is "cp"
if matches.get_flag("json") && command != "cp" {
let json_error = json!({
"status": "error",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

reduct-rs sdk returns the ReductError with a status and an error message. I think we can attach it to the anyhow error and downcast here to get the status. See https://docs.rs/anyhow/latest/anyhow/trait.Context.html.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah I didn't know that ReductError error has status code too. I'll update the code.

@atimin

atimin commented Jul 22, 2026

Copy link
Copy Markdown
Member

Hi @vbmade2000 , I think it's a good approach but we could try to improve the error handling without breaking the interfaces.

Signed-off-by: Malhar Vora <mlvora.2010@gmail.com>
@vbmade2000

Copy link
Copy Markdown
Contributor Author

@atimin I have updated code to return status code.

@vbmade2000
vbmade2000 requested a review from atimin July 22, 2026 14:37
Signed-off-by: Malhar Vora <mlvora.2010@gmail.com>
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.

Task: add --json output for bucket commands

2 participants