Endilll / vapoursynth-preview

Preview for VapourSynth scripts
Apache License 2.0
69 stars 21 forks source link

Add --external-args option forwarded to script #5

Closed wallace11 closed 4 years ago

wallace11 commented 4 years ago

As we discussed earlier. It seems to work fine with just setting sys.argv. Tested with a script with argparse. I have no idea if it works with other libraries as well (click, etc...).

If there's something with the implementation that bothers you, please tell me and I'll make changes accordingly.

wallace11 commented 4 years ago

Improved the implementation to work in the following manner:

  1. load_script accepts an optional external_args argument.
  2. If argument is provided, stores it as instance attribute.
  3. Stores original sys.argv locally.
  4. Fakes sys.argv by trying to write it with the external_args instance attribute.
  5. Loads script.
  6. Restores original sys.argv.

Also: