Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --extract flag to output Python code #40

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

katrinafyi
Copy link

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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature suggestion: extract Python code only
1 participant