Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli.js output is inconsistently not JSON #979

Closed
alxndrsn opened this issue Sep 13, 2023 · 1 comment · Fixed by #1110
Closed

cli.js output is inconsistently not JSON #979

alxndrsn opened this issue Sep 13, 2023 · 1 comment · Fixed by #1110
Assignees
Labels

Comments

@alxndrsn
Copy link
Contributor

alxndrsn commented Sep 13, 2023

Observed

user-create - javascript

$ node lib/bin/cli.js --email someone@example.com user-create
{
  email: 'someone@example.com',
  id: 123,
  type: 'user',
  displayName: 'someone@example.com',
  createdAt: 2023-09-13T00:00:00.001Z,
  updatedAt: null,
  deletedAt: null
}

user-promote - JSON inside quotes

$ node lib/bin/cli.js --email someone@example.com user-promote
'{"success":true}'

user-set-password - JSON inside quotes

$ node lib/bin/cli.js --email someone@example.com user-set-password
prompt: password:  ******************

'{"success":true}'

Expected

I think helpful output would be either:

  1. parsable JSON, or
  2. proper English
@alxndrsn alxndrsn added the bug label Sep 13, 2023
@alxndrsn alxndrsn changed the title cli user-promote prints JSON inside quotes cli output is not JSON Sep 13, 2023
@alxndrsn alxndrsn changed the title cli output is not JSON cli output is inconsistently not JSON Sep 13, 2023
@alxndrsn alxndrsn changed the title cli output is inconsistently not JSON cli.js output is inconsistently not JSON Sep 13, 2023
@alxndrsn
Copy link
Contributor Author

The inconsistency comes from the behaviour of the serialize() function in lib/util/http.js. It may not be helpful to use this function for CLI tasks.

alxndrsn pushed a commit to alxndrsn/odk-central-backend that referenced this issue Mar 17, 2024
* only call jsonSerialize() for HTTP output when it is required
* always output JSON from task.run()

Closes getodk#979
alxndrsn added a commit that referenced this issue Mar 21, 2024
* only call jsonSerialize() for HTTP output when it is required
* always output JSON from task.run()

Closes #979
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ done
Development

Successfully merging a pull request may close this issue.

1 participant