allow no output filename
Allow to call weasyprint CLI without output filename. The default output filename is input filename followed by .pdf.
(Everytime I use weasyprint, I forget to provide output filename…)
Hi,
Thanks for this pull request! 🙏🏽
That’s a good idea, but I have some concerns about the current implementation:
- When
document.htmlis given, I think I’d prefer to getdocument.pdf, notdocument.html.pdf. - When a URL is given (for example
weasyprint https://weasyprint.org/), we currently get a crash.
We can first decide which "good" filename we want to get for these common cases (and maybe look at what other widely used tools do):
documentdocument.html../../folder/document.htmlhttps://example.org/https://example.org/indexhttps://example.org/index.phphttps://example.org/index.php?a=b&c=d- … (you’ll for sure find other ones!)
And then, we’ll find a simple, clean and reliable way to get this! 😄
Hello, who was that question for? Here is my unrequested opinion:
| source | target |
|---|---|
| document.html | ./document.pdf |
| document | ./document.pdf |
| document.foo | ./document.pdf |
| document.foo.bar | ./document.foo.pdf |
| ../../folder/document.html | ./document.pdf (*) |
| https://example.org/ | ./output.pdf (or some other default) |
| https://example.org/path/index | ./index.pdf |
| https://example.org/path/index.php | ./index.pdf |
| https://example.org/path/index.php?a=b&c=d | ./index.pdf |
| https://example.org/path/index#a=b;c=d | ./index.pdf |
(*) not sure of this, but I think that's a good choice about write permissions on filesystem
@liZe I don't have the time right now, maybe in july. The suggestions of @luca-vercelli look good to me. What do you think?
@liZe I don't have the time right now, maybe in july. The suggestions of @luca-vercelli look good to me. What do you think?
@vpoulailleau Looks good to me. You can write a dedicated function for that, so that we can easily test it.
(I really hope that it won’t be too complex though. Comments like the ones in this thread may help to find corner cases.)
about the case of ../../folder/document.html, I agree with you, not necessarily because of permissions but simply because the default behavior most users expect (and is what most programs implement, I believe) is that if you run a process in a directory, the output will be in that directory.