On some devices which do support WiFi-Direct, the corresponding binaries come pre-installed (e.g. the
wpa_cli command; see also How can I install wpa_cli on my rooted device?). If you have those ready, you can use them on your Android device as you would do on a Linux machine (find a closer description e.g. in the blog post How To : Use wpa_cli To Connect To A Wireless Network).
Of course that would require a terminal emulator to be installed on your device (take e.g. a look at Android Terminal Emulator for a good candidate) -- at least if you want to issue the commands directly.
As the linked "How To" describes, you can use
wpa_cli in interactive mode (by directly executing it). On the "wpa_cli shell" you then can execute different commands:
scan scans for available networks, with
add_network you can select an available network to configure with
set_network. An example could look like this:
> set_network 0 ssid "WLAN-Network"
> set_network 0 psk "SupahSecretPassphrase"
This would trigger a connection phase, which could look like:
> <2>Trying to authenticate with 00:55:ab:25:ac:5a (SSID='WLAN-Network' freq=2437 MHz)
> <2>Trying to associate with 00:55:ab:25:ac:5a (SSID='WLAN-Network' freq=2437 MHz)
> <2>Associated with 00:55:ab:25:ac:5a
> <2>WPA: Key negotiation completed with 00:55:ab:25:ac:5a [PTK=CCMP GTK=CCMP]
> <2>CTRL-EVENT-CONNECTED - Connection to 00:55:ab:25:ac:5a completed (reauth) [id=0 id_str=]
Another good source to take a look at is Android from the command-line, which gives some more examples -- not only restricted to WiFi.