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

[Improvement] Silent flag for API calls #109

Open
darkspirit510 opened this issue Nov 9, 2021 · 2 comments
Open

[Improvement] Silent flag for API calls #109

darkspirit510 opened this issue Nov 9, 2021 · 2 comments

Comments

@darkspirit510
Copy link

darkspirit510 commented Nov 9, 2021

Hi all,
i'm passing CLI JSON results to jq. A few months ago I created some scripts that were able to trim the header (something like CLI has been refactored...). Now my scripts don't work anymore because the header changed:

Calling: caprover api -t "/user/apps/appDefinitions/" -m GET -d "{}" results in

Call generic CapRover API [Experimental Feature]...

Ensuring authentication...
API call completed successfully!

{
  "appDefinitions": [
    {
[...]

Which (without trimming) of course make jq complain since this is no JSON. Can you please add a silent flag (something like -s) to get rid of everything except JSON? Thank you :-)

@githubsaturn
Copy link
Collaborator

If you need the output, why aren't you making use of -o output.json flag?

@darkspirit510
Copy link
Author

I like to chain things without writing and catting files. From my setup script:

APP_EXISTS=$(caprover api -t "/user/apps/appDefinitions/" -m GET -d "{}" | tail -n+8 | jq ".appDefinitions[] | select(.appName == \"$CAPROVER_APP\")")
if [ -z "$APP_EXISTS" ]; then
  echo "Creating new dummy app '$CAPROVER_APP' 🐣"
  caprover api -t "/user/apps/appDefinitions/register" -m POST -d "{\"appName\":\"$CAPROVER_APP\", \"hasPersistentData\": false}"
else
  echo "App '$CAPROVER_APP' already exists 🥱"
fi

I know and use the same approach for things like CloudFoundry or any web api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants