You can do both if that even without CLI just with a serial monitor (e.g. PuTTY).
If you set the baudrate to 14400 you can trigger DFU mode.
If you can get your device into Listening Mode, send w to the device to prompt you for the WiFi credentials, but with the network not present or hidden, you need to set security and encryption cipher too.
Update:
28800 enters YModem Mode for firmware upload.
Unfortunately there doesn’t seem to exist such a handy way to enter Listening Mode, but you could add such a part into your program that exposed a way to call WiFi.listen(); or WiFi.setCredentials() directly.