-
Notifications
You must be signed in to change notification settings - Fork 7
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
Guess the output format based on the --output argument #160
Comments
This issue has not been active since a lot of time. If you think it is still valid, feel free to reply with a simple comment. Without any update, I will close it in 7 days. |
Nope, you don't want to close that. 👀 |
This issue has not been active since a lot of time. If you think it is still valid, feel free to reply with a simple comment. Without any update, I will close it in 7 days. |
I see that you self-assigned this issue. Are you currently working on this? If not, I would love to give it a shot. |
Hello, no, I haven't started it yet, you can take it. |
I am having some issues running using the different output types, specifically on this line. When I use json or text, I have to remove the "b" from the arguments so the file isn't opened in binary mode or else I see this error: |
No, I think I see what you are facing. It is a bit tricky, since the PDF format is a binary format, but not the plain text and JOSN format. def get_opening_mode(format: str) -> str:
if format == "pdf":
return "wb"
return "w" WDYT? |
Ok, just wanted to make sure. I like the solution you suggested! |
I have something working now. I think all that is left is to add some tests. Would I add these in the end to end test script? |
I think you can add them just after the existing export ones :) |
(Feature request by @AmauryCarrade on Discord)
Is your feature request related to a problem? Please describe.
Currently, to export in a PDF file, we need to give two arguments to the command:
--format=pdf
--output=myfile.pdf
Giving both arguments, even though acceptable, is redundant.
Describe the solution you'd like
--format
argument becomes optional.--format
and--output
is given, then the behavior stays the same as today: the content is output in the given file using the given format, even though the extension does not match the format.--output
is given, then guess the format to use from it:--output=myfile.txt
ou--output=myfile
(without extension) will output a file containing the text usually returned in standard output--output=myfile.json
will output a file containing a JSON content--output=myfile.pdf
will output a file containing the PDF content--output
is given, but the file format is not recognized, then an error is returned and nothing is done.The text was updated successfully, but these errors were encountered: