cog icon indicating copy to clipboard operation
cog copied to clipboard

add --extract flag to output Python code

Open katrinafyi opened this issue 1 year ago • 0 comments

implements --extract flag, fixes #39.

the implementation is rather unsatisfactory. it is done by "pretending" the code has generated the Python source as its output and then setting no_generate = True and delete_code = True. semantically, this new option is a combination of a hypothetical "delete_text" and then no_generate.

happy to take major feedback and suggestions.

example cog:

preceding text
[[[cog
cog.out("chunk1")
]]]
[[[end]]]
centre text
[[[cog
cog.out("chunk2")
]]]
[[[end]]]
following text

example output:

# <cog a.cog:2>
import cog
cog.out("chunk1")

# <cog a.cog:7>
import cog
cog.out("chunk2")

katrinafyi avatar Sep 29 '24 03:09 katrinafyi