urfave / cli

A simple, fast, and fun package for building command line apps in Go
https://cli.urfave.org
MIT License
21.9k stars 1.69k forks source link

Fix:(issue_1607) Allow exporting command and arguments/options to json #1855

Closed dearchap closed 6 months ago

dearchap commented 6 months ago

What type of PR is this?

(REQUIRED)

What this PR does / why we need it:

(REQUIRED)

Allows us to have a starting point for a framework for exporting cli to JSON.

Which issue(s) this PR fixes:

(REQUIRED)

Fixes #1607

Special notes for your reviewer:

(fill-in or delete this section)

Testing

(fill-in or delete this section)

Added a new test case TestJSONExportCommand which shows that the entire command graph can be exported to JSON.

Release Notes

(REQUIRED)

Once a root command is constructed. json.Marshal can be used to export the command graph to a string of bytes. This can be piped to a template rendering tool such as [tpl](https://github.com/bluebrown/go-template-cli)  along with a template file to render markdown/man pages. 
github-actions[bot] commented 6 months ago
[![👍 Frogbot scanned this pull request and found that it did not add vulnerable dependencies.](https://raw.githubusercontent.com/jfrog/frogbot/master/resources/v2/noVulnerabilityBannerPR.png)](https://docs.jfrog-applications.jfrog.io/jfrog-applications/frogbot)
Note: ---
**Frogbot** also supports **Contextual Analysis, Secret Detection, IaC and SAST Vulnerabilities Scanning**. This features are included as part of the [JFrog Advanced Security](https://jfrog.com/advanced-security) package, which isn't enabled on your system.

[🐸 JFrog Frogbot](https://docs.jfrog-applications.jfrog.io/jfrog-applications/frogbot)