-
Notifications
You must be signed in to change notification settings - Fork 226
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
[feature] Read from stdin and write output (PNG, SVG) to stdout #320
Comments
Thank you for the suggested functionality. A lot of new code has just recently been merged into the It seems you intend to use a single input file named "-" as a flag to read from STDIN. What will happen if a set of input files are specified, and one of these is named "-"? Is it then possible to read STDIN for that single file while processing the other input files normally? Independently from my question above, what should be the condition for writing an output file to STDOUT?
Have you checked how well known Unix CLI tools (also able to process multiple input files) handle the conditions I describe above? |
As far as I know, you should not use a file named $ vim -
Vim : Reading stdin... $ echo 'hi' > - $ cat - The above command will wait for stdin 😱 I think we can use the same behavior as $ cat test.txt
hi $ cat test.txt test1.txt
hi
bonjour stdin ignored if a file is provided: $ echo 'hello' | cat test.txt
hi $ echo 'hello' | cat
hello $ echo 'hello' | cat -
hello Read the file then read from stdin $ echo 'hello' | cat test.txt -
hi
hello
By default, we should output to stdout when
The above option means output to
I guess we should output them to stdout in the order they are specified.
You mean: $ wireviz test.yml -f svg -o - The above command will read
Since an input file should not be named Read from stdin, output to out.svg cat input.yml | $ wireviz -f svg -o out.svg - Read from stdin (empty), read from input.yml, output to out.svg $ wireviz input.yml -f svg -o out.svg - |
I have not considered this option, and as someone who is not a very heavy CLI user, I don't feel qualified to argue in favor or against such a feature. Feel free to play around with the |
I agree that when "-" as input file should be interpreted as STDIN, then "-" as output file I'm not sure if it makes sense to output more than one file format to STDOUT, but try it out to see if it can be usable. There are a few places in the code where some warning text is written to STDOUT. Please make sure they are all written to STDERR to avoid possible conflicts with an output file written to STDOUT. |
In my opinion, the WireViz/src/wireviz/wireviz.py Lines 24 to 31 in 92af905
I think it would be better to handle the output part in another function. def parse(
input: Union[Path, str, Dict],
image_paths: Union[Path, str, List] = [],
) -> ParseResult: I would argue that def parse(
input: Union[Path, str, Dict],
options: dict,
) -> ParseResult: Then, we could have functions on the parse_result.pipe(format="svg", encoding="utf8") # str
parse_result.pipe(format="png") # bytes
parse_result.save(filename) # str -> path where the file was saved |
Your arguments about the |
I think our goals are aligned:
For reference, I didn't include this change as part of #321 |
What happens if any connector or cable contains an image? Where should WireViz look for image files with relative paths when the YAML input is read from STDIN? Maybe #322 might help? |
We are using a
Indeed, embedding image as base64 is more portable since you don't rely on relative paths/external resources. |
@kvid @formatc1702 Hey! Is the |
@ggrossetie wrote:
To be honest, I don't know. I've not had time to check out all the new code merged into What I do know, is that all commits to resolve change requests of the old PRs he merged into
If you are in a hurry and need something stable, then I guess it's safer to use v0.3.2 as a base. Is that possible for you, or do you need some new features that currently are only in the |
Thanks for your input.
Let me know if I can help.
I think I should be able to backport #321 on the 0.3.2 release. |
Thank you for offering your help! Any kind of help is highly appreciated, e.g. testing new code against existing example inputs (and new test cases when needed), inspecting code to identify edge cases and/or code improvements, detect missing/confusing/wrong documentation, etc. Be aware that #251 contains a lot of commits (I found it a bit overwhelming to go through each of them), but just looking at Files changed is perhaps a better approach. If you are willing to checkout the refactor/big-refactor branch and help identifying issues that need improvements, then I suggest classifying them into e.g.
You can make comments at any changed code line, suggest improvements, and/or write a summary comment. You can choose to connect such comments into a review with a final summary comment, or just write independent comments. See also #316 - where we discuss the the process of finalizing these PRs.
I suggest a new PR (with |
Hey!
Would it be possible to support the following usage from the CLI:
The above command will read the YAML file from the stdin and generate/write an SVG to stdout.
I can submit a pull request to implement this feature.
The text was updated successfully, but these errors were encountered: