pizza-cli icon indicating copy to clipboard operation
pizza-cli copied to clipboard

Feature: Support `--output/-o` flag globally for yaml, json, and csv outputs

Open jpmcb opened this issue 9 months ago • 1 comments

Type of feature

🍕 Feature

Current behavior

There's no great way to "save" contributions besides piping the table output through standard out to a file:

❯ pizza insights contributors https://github.com/open-sauced/api > my-api-stats.txt
❯ cat my-api-stats.txt

 Repository URL        https://github.com/open-sauced/api
 New contributors      3
 Recent contributors   8
 Alumni contributors   4
 Repeat contributors   5

That works great, but the our output table isn't really standardized and doesn't allow for much composability with other CLI or data tools.

We should aim to support 3 formats wherever possible: yaml, json, and csv.

Suggested solution

Add a --output/-o flag that accepts yaml, json, or csv

❯ pizza insights contributors https://github.com/open-sauced/api -o csv
Repository URL, New contributors, Recent contributors, Alumni contributors, Repeat contributors, Repeat contributors
https://github.com/open-sauced/api, 3, 8, 4, 5

this can then be piped to a .csv file and loaded into common programs like Excel.

The yaml and json outputs are alittle more straightforward:

❯ pizza insights contributors https://github.com/open-sauced/api -o
---
Repository URL: https://github.com/open-sauced/api
New contributors: 3
Recent contributors: 8
Alumni contributors: 4
Repeat contributors: 5
❯ pizza insights contributors https://github.com/open-sauced/api -o
{
	"Repository URL": "https: //github.com/open-sauced/api",
	"New contributors": 3,
	"Recent contributors": 8,
	"Alumni contributors": 4,
	"Repeat contributors": 5
}

Additional context

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

Contributing Docs

  • [X] I agree to follow this project's Contribution Docs

jpmcb avatar Sep 27 '23 16:09 jpmcb