Welcome to PlantUML Q&A, where you can ask questions and receive answers from other members of the community.

You can also submit new features request and vote for them.

How to start generating picture with pipe mode

0 votes

I'm trying to use plantuml "-pipe" parameter to start plantuml only once for generation of many pictures.

But it seems that the generation only takes place if stdin is getting closed. This means I have to start

plantuml again which costs time. Is there a possibility to let plantuml run once and to put one picture description

via stdin after another with getting one picture after another via stdout (with apropriate separator)?

With kind regards,

asked 4 days ago by anonymous

1 Answer

0 votes
We've just published a new beta https://www.dropbox.com/s/koo42q3d9gxw288/plantuml.jar?dl=0

This beta should better handle the -pipe option : you can now send several diagrams in stdin (please use appropriate @startXXX / @endXXX delimitor for those diagrams).

Right now, there are no delimitor between pictures in stdout : you have to detect PNG header start : is it possible for you ?

In the future, we may add some optional delimitor (using for example a -delimitor flag) in the command line.

This has not been widely tested, so please feedback if you find issues!


PS: Note that you could also use the FTP option to generate several diagrams without having to restart java process. See http://plantuml.sourceforge.net/qa/?qa=5694/c%23-plantuml-jar-alternative
answered 4 days ago by plantuml (111,340 points)
thanks for the answer. I will try the FTP mode soon.
With the new version the behavior of the -pipe mode is the same.
As long as I not close the pipe plantuml is not generating any picture.
To eliminate any problem with the PNG output I set the output format
to -ttxt. With the -verbose parameter I get the start information, but
no pictures. Is there another way to dig it down?

With kind regards,
We've made some change in the newest beta (beta 4)
Could you try it ?
(And send us the output of -verbose if it does not work better)
Try also to send many diagrams (1000?) to the input stream to see if the generation starts before pipe close.
This one I tested. My problem is, that my test is in the form that I start
a process from within emacs (on windows, same on Linux) in an comint buffer and then send via
comint-send a diagram. But the comint buffer does not show the result.

  (apply 'make-comint "plantuml" "java" nil '("-jar" "plantuml.jar" "-pipe" "-tutxt" "-verbose"))
  (switch-to-buffer-other-window "*plantuml*")
  (other-window -1))

(comint-send-string (get-buffer-process "*plantuml*") "@startuml\n Alice -> Bob\n @enduml\n")

Results in the *plantuml* buffer:
(0.000 - 243 Mo) 238 Mo - PlantUML Version 2017.08beta3
(0.020 - 243 Mo) 238 Mo - GraphicsEnvironment.isHeadless() false

But not more if evaluating the comint-send-string.

To check the result I tried:
  (apply 'make-comint "cmd" "cmd" nil '())
  (switch-to-buffer-other-window "*cmd*")
  (other-window -1))

(comint-send-string (get-buffer-process "*cmd*") "dir\n")

which works flawlessly sending the dir output to the *cmd* buffer.
I tried it also on Linux with the same negative result, so I'm convinced
that this is no problem of windows.

Is there a possibility to give more debug output?
Could you test with beta 4 ?
(The logs says PlantUML Version 2017.08beta3 )
I tested on Linux (can do the same tomorrow on Windows) with beta5 same way as described above, gives:

(0.000 - 240 Mo) 234 Mo - PlantUML Version 2017.08beta5
(0.025 - 240 Mo) 234 Mo - GraphicsEnvironment.isHeadless() false
(0.099 - 240 Mo) 233 Mo - managePipe::before readOneDiagram
(5.707 - 240 Mo) 233 Mo - one line read:@startuml

(5.709 - 240 Mo) 233 Mo - one line read: Alice -> Bob

(5.709 - 240 Mo) 233 Mo - one line read: @enduml

But no diagram output.

With kind regards,
There seems to be an extra space between : and @ in
(5.709 - 240 Mo) 233 Mo - one line read: @enduml
Can you double check that there are no space before @enduml ?
Oh damn,... that's it.
Thank you for your patience and quick help.
I will try it tomorrow on Windows.

Now it is the time to ask if it would be possible to implement the "-delimitor" flag, so that I can define the delimiter which comes directly after the generated picture.

With kind regards,
Great! That's nice!
So we've just built a new beta (beta6) https://www.dropbox.com/s/koo42q3d9gxw288/plantuml.jar?dl=0

In this beta, we have slightly changed some code about pipe reading (basically because the previous beta were not dealing the charset).
So if there is a regression with -pipe option please tell use.

We have also added a -pipedelimitor flag, so that you can do:
java -jar plantuml.jar -pipe -pipedelimitor XXXXXXXXX

Tell us tomorrow if it matches your need!
Thanks. Looks nearly good. Would it be possible to print the delimitor in time directly at the end of the generated picture, then I can use it as the end marker of the generation. It seems that you print it only before outputting the next picture.

With kind regards,
Ok, beta7 should do the job
Feedback welcome!
Thanks for all. This works like expected under Windows. I will now
try to but all the pieces together for what I want.
Thanks very much.
With kind regards,
Hello again,
I tried some things and there is sadly one more problem:
For my plan I send nearly every keystroke via pipe to plantuml, so they script is not syntactically correct some times. In this situation I get:
     ┌─┐          ┌─┐
     │A│          │B│
     └┬┘          └┬┘
      │            │
     ┌┴┐          ┌┴┐
     │A│          │B│
     └─┘          └─┘
.. (skipping 9 lines) ...
A -> B                    
 Syntax error: E          
Syntax error: E

In this example, same as if using -tpng, I sent a correct description,
-pipedelimiter is "===END-OF===", and afterwards a false one.

In this situation the error is given as text, which is a picture with -tpng. But after the delimiter I get additional text which is necessary for
telling the user where the error is, but it comes after the delimiter.

Would it be possible to:
- have the delimiter at the end of all
- the error description as picture (for tools which need this)
- and an additional error message in ascci, as if using -tutxt,
  which would it make simpler to show the user the previous picture
 and an error message as overlay right in the source.
Perhaps an the mechanism of the delimiter can be changed to have
an real end marker and perhaps a separator of the parts of the answer.

I hope I have clearly written down my problem, looking forward for
an answer.

With kind regards,
Do not worry about iterative development : this is usually how we work.

Firstly, diagrams images (PNG or ASCII) are sent to Standard Ouput and error message are sent to Error Ouput, so there should not need to separate them (they are not in the same flow).
Printing information to Error Ouput was useful when only one diagram was generated.
I've got the feeling that you are using PlantUML in some daemon mode here, to printing information to Error Ouput maybe make no sense.

So in last beta, we decided to remove any flow to Error Ouput when -pipedelimitor is used. Note that this is not a final decision, just a try.

Does it make it easier to use for you ?
Support This Project Offer 250 Mo! Follow PlantUML on Twitter