Setting upload_protocol and upload_flags from cli

Hello
Is there a way to set upload_protocol and upload_flags from CLI?

I have setup where I develop on ESP8266 based hardware with multiple configurations. I need to deploy code to few boards. Some of them are connected via USB and some programmed via OTA.

The problem is that changing values of upload_protocol or upload_flags in platformio.ini results in rebuilding whole project, when no “real” changes are made just upload method is changing.

Is there a way to overcome this? For now I have build a set of scripts using esptool.py and espota.py (Arduino/tools/espota.py at master · esp8266/Arduino · GitHub) but would be better if that could be achieved just using pio command line…

Please have a look at this - I think you could solve your problem in a similar way, i.e. use distinct environments in which you define the different settings needed