Well, I answered my own question using some hints in the code from the docs MongoDB provided. I’m just posting here in case anyone else runs into this issue in the future.
The hint was the example code had an echo command in it, which means we can send some text into the command.
So when you do “realm-cli describe”, and you’re being asked to manually/interactively select the app from the list, it will take “type to filter”, not just arrows. So if you know the name of your app, or even the first part of it, you can echo in the app name and it will autoselect it for you !
In the example below, you’d just change:
DESCRIBE_APP_SOURCE=$(realm-cli app describe)
to
DESCRIBE_APP_SOURCE=$(echo "app1" | realm-cli app describe)
Very happy it was this easy.
I’m using the following code to determine the appid in MongoDB Atlas. This works great if there’s only 1 app, but if more than 1, it’s asking to select the app manually, which cannot be done through realm-cli scripting.
Is there any way around this or some way I can script auto-selecting the app ?
DESCRIBE_APP_SOURCE=$(realm-cli app describe)
APP_ID_SOURCE=$(echo ${DESCRIBE_APP_SOURCE} | sed 's/^.*client_app_id": "\([^"]*\).*/\1/')
REALM_APPLICATION_ID_SOURCE=${APP_ID_SOURCE}
? Select App [Use arrows to move, type to filter]
> app1-dsfas (9999999999999999999999)
app2-asdfs (999999999999999999998)
app3-dfasd (9999999999999999999997)