clasp
clasp copied to clipboard
feat: Add global --json flag for commands
This change introduces a global --json flag to provide command output in a machine-readable JSON format.
Key changes:
- Added a global
--jsonoption insrc/commands/program.ts. - Removed local
--jsonflags fromsrc/commands/show-file-status.tsandsrc/commands/tail-logs.ts. - Updated all commands to utilize the global
--jsonflag and output appropriate JSON structures when the flag is present.- For commands that output lists of items (e.g.,
list-scripts,list-deployments), the JSON output is an object containing an array of those items. - For commands that perform actions (e.g.,
create-script,deploy), the JSON output includes relevant identifiers (like scriptId, deploymentId, version) or status messages. - For commands that open URLs, the JSON output is
{"url": "openedUrl"}and the URL is still opened in the browser. - Informational text messages are suppressed when
--jsonis active.
- For commands that output lists of items (e.g.,
- Updated or created unit tests for all commands to ensure:
- Correct JSON output when the
--jsonflag is used. - Continued correct behavior for standard text output.
- Proper mocking of dependencies and use of the
runCommandutility. - Verification that text output is suppressed when JSON output is active.
- Correct JSON output when the
Fixes #<issue_number_goes_here> (it's a good idea to open an issue first for discussion)
- [ ]
npm run testsucceeds. - [ ]
npm run lintsucceeds. - [ ] Appropriate changes to README are included in PR.