Fix bug in cli argument parsing

The argument list was being manipulated inside the for loop.
This was causing the loop to behave very strangely on some systems.
The loop would exit after the first iteration and the command would
exit with an error
Merge pull request #717 from mahendra/args

Fix bug in cli argument parsing
prevent exception when using -P without a start_action