beryx / text-io

A library for creating interactive console applications in Java
http://text-io.beryx.org/
Apache License 2.0
342 stars 45 forks source link

Specific Maven example for WebTextTerminal #31

Closed maxbrito500 closed 3 years ago

maxbrito500 commented 3 years ago

Hallo Serban,

Many thanks for making available text-io, I think it is fantastic and the best tool in the java world for providing a command line regardless of the interface.

Both the console and swing versions worked great out of the box, was possible to learn how to use them very quickly. My difficulty is with the WebTexTerminal. I'm struggling to get it working under Maven without success so far. I'm able to compile the Gradle demo, but unable to port this into the maven project. The documentation available on this part I'm unfortunately unable to follow and understand what is missing.

Would it be possible to ask for a quick demo specifically written in Maven just for the WebTextTerminal?

Many thanks in advance.

siordache commented 3 years ago

See this: https://github.com/beryx-gist/text-io-demo-standalone

maxbrito500 commented 3 years ago

Thank you so much Serban!

It worked right on the first run, comparing to this demo was able to find what was wrong (location of the resources). Also, on the command line is necessary (at least on my machine) to press ENTER twice to launch the web browser. We first choose 6 (doesn't really matter which app), then press 6 again (terminal to be used) and then press 1 (RatPack). To launch the web browser only happens after pressing ENTER once again, which might be confusing to other users.

Anyways, that is just a side note. Thank you for the quick answer and demo. Will later provide back the link where it is being used (an open source portal)

maxbrito500 commented 3 years ago

Found the issue behind needing to press ENTER. It was the question for confirming the port number to be used. On the IDE console this question was not appearing but debugging the code was possible to see what happened. No troubles now, everything perfect.

In case this helps other people in the future, here is minimum code required for the WebTextTermina launched on port 8080l:

    public static void main(String[] args) {
        BiConsumer<TextIO, RunnerData> app = new Weather();
        WebTextTerminal term = new WebTextTerminal();
        term.init();
        TextIO textIO = new TextIO(term);
        WebTextTerminal webTextTerm = (WebTextTerminal) textIO.getTextTerminal();
        TextIoApp<?> textIoApp = new RatpackTextIoApp(app, webTextTerm);

        WebTextIoExecutor webTextIoExecutor = new WebTextIoExecutor();
        webTextIoExecutor.withPort(8080);
        webTextIoExecutor.execute(textIoApp);
    }