Details
Description
When mender-cli does not have a proper JWT token to the server it will create very confusing error messages.
For example:
$ mender-cli terminal --server "https://mender.example.com" c5f90b7c-bb8f-4527-8658-4352ae2500a4 Configuration file not found. Continuing. Connecting to the remote terminal of the device c5f90b7c-bb8f-4527-8658-4352ae2500a4... FAILURE: Unable to connect to the device: websocket: bad handshake
Also see the thread here: https://hub.mender.io/t/bad-handshake-with-mender-cli
We should improve the usability of the "login" feature and features depending on it.
Acceptance criteria:
- All mender-cli commands that require a login generate an error if you are not logged in (i.e. authenticated successfully). It suggest running mender-cli login.
- The --server argument is saved together with the login token. (Now It seems you have to pass --server for every single command now (unless you use hosted), which defeats the usability of login)
- For the Troubleshoot features requiring instant access to a device, the error message indicates if a device is not connected to the Mender server (similarly to what we have in the UI)