cliinterface: refactor the replacement of ExtractArgs
The old algorithm used to edit the list of ExtractArgs by using indexes.
This was a mess and there was a bug in the replacement of PasswordSwitch.
We now create an empty list, which we populate while iterating over
the list of ExtractArgs. The replacement of each switch is performed in a
dedicated function, to simplify the implementation.
Unit tests are added, though only for clirar (for now).
Differential Revision: D1190