As @_j pointed out, you’d have to implement an environment that lets the model “see” the file, write its code and execute it.
While it may be technologically complex to do on your own, there’s a very recent open-source project called open-interpreter
that could, to an extent, replicate that functionality natively on your terminal.