I have all the details to connect to a particular access point. I have to use that access point only, so all I require is the command to do it.
Late to the party, but I came up with a way to accomplish this on a device without root.
It may not be pretty, but it works.
Basically what I propose is to create an app that joins an access point based on EXTRAS given when starting the app.
The EXTRAS are then provided using the am command's -e parameter.
I already build an app which does so and it's available here: https://github.com/steinwurf/adb-join-wifi
Once the app is installed, a wifi access point can be joined using the following ADB command:
adb shell am start -n com.steinwurf.adbjoinwifi/com.steinwurf.adbjoinwifi.MainActivity -e ssid [SSID] -e password_type [PASSWORD_TYPE] -e password [WIFI PASSWORD]
There's more info in the README on Github.
Hope it helps someone.