More robust docopt argument parsing for spaces in DJANGO_OPTIONS with kalite command
Branch: 0.14.x
There are a number of known issues with the parsing of additional (DJANGO_OPTIONS) arguments passed to the kalite command. One is covered in https://github.com/learningequality/ka-lite/issues/4039, and the other is:
- Spaces cannot be used in arguments, as the parsing is not parenthesis-aware (e.g.
--data='{"key":"val"}'not--data='{"key": "val"}')
This restriction is causing problems in the central server testing, where we pass arguments to set up data when we orchestrate multiple distributed servers, including quoted strings with spaces in them, and JSON data.
It could also cause problems in practice, where we pass arguments with spaces from the installers or where users do so -- e.g. with the runcode command, which we have at times told users to run with some custom code in order to fix a problem they had.
This example, which I expected not to work, actually works fine: bin/kalite manage runcode "from securesync.engine.models import ImportPurgatory; ImportPurgatory.objects.all().delete()"
(it seems the problem is only when the spaces are inside the argument to a named option)
How about we work out a proper fix for proxying DJANGO_OPTIONS for 0.15 and backport it to 0.14 ? Regardless of how thin and beautiful our command line parser ends up, we should add some tests for it as well to make it more robust. Lately, we've gained a lot of inspiration for test cases :)
This can now be solved the same way that it's done in Kolibri.