workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

🚀 Feature Request: Have something like tail's `format` flag for all wrangler commands

Open fubhy opened this issue 3 years ago • 6 comments

Describe the solution

Related: https://github.com/cloudflare/pages-action/issues/29

It would be great if the CLI supported a global --json flag for producing JSON output for all commands. That would make leveraging the CLI in CI much more painless. The entire aformentioned github action could then be replaced by npx wrangler publish --json | jq ... to grab the relevant output for instance.

fubhy avatar Oct 12 '22 10:10 fubhy

Could you give an example of the type of output you'd like to see from npx wrangler publish --json?

penalosa avatar Oct 12 '22 11:10 penalosa

For instance, when you run npx wrangler pages deployment list, you get Environment │ Branch │ Source│Deployment │ Status │ Build

For npx wrangler pages publish --json I'd expect the same values (and maybe others too, like number of deployed files, number of functions, function paths, etc. [?!]) in JSON format.

fubhy avatar Oct 12 '22 11:10 fubhy

Ah ok, so essentially something like wrangler tail --format json but for publishing? Hmm...

caass avatar Oct 13 '22 00:10 caass

Yes. For all commands so thart the outout can easily be piped into e.g. 'jq' or used in other tools more easily without trying to parse it from human readable output

fubhy avatar Oct 13 '22 05:10 fubhy

This would also help with the github action - https://github.com/cloudflare/wrangler-action/issues/77 Currently one has to find the deploy url in the logs of the action.

rohit-gohri avatar Nov 03 '22 15:11 rohit-gohri

Contributing to this worthwhile goal: #6570

mlafeldt avatar Aug 26 '24 09:08 mlafeldt

I stumbled upon parsing code that tediously processes wrangler's terminal output , I agree that it would be wonderful to have the option for JSON output everywhere. Please see: https://github.com/Dhravya/cloudflare-saas-stack/blob/main/scripts/setup.ts#L29 - it would unlock a lot of automatio, bot locally and in the deployment process.

mxschumacher avatar Sep 11 '24 06:09 mxschumacher

Oh no. I just landed here, because I need to do the same thing–automatically deploy a site and use the deployment URL in another step. I really need to parse the fancy table output..?

Radiergummi avatar Mar 19 '25 07:03 Radiergummi

Thanks for raising this feature request, and apologies for the delay! Instead of parsing Wrangler's output, we'd recommend using the WRANGLER_OUTPUT_FILE_DIRECTORY environment variable, which when provided to Wrangler when deploying will make Wrangler write an ND-JSON description of the deployment to that directory, including details like deployment & preview URLs. This feature is not currently documented, but was added in: https://github.com/cloudflare/workers-sdk/pull/6383

penalosa avatar Oct 07 '25 16:10 penalosa