sbt clear screen command - scala

I am learning sbt build tool. I use interpreted sbt. I run lot of commands and get lot of output which clutters up the screen.
The question is any command for clear screen for sbt interpretive console , like cls in DOS shell or clear in bash
My googling skill did not helped
update : i am using console2 with windows power shell

In bash you should be able to use Ctrl+L, on OSX you can also use Cmd+K.

This specifically helps when you're doing something in continuous mode, ala `compile:
maxErrors := 5
triggeredMessage := Watched.clearWhenTriggered
This works as of 0.13.7. The second line clears the screen before each command runs. The first line limits the number of errors. With this config, you only ever have one screen full of errors to work through. Obviously could adjust maxErrors depending on your sbt window.

Sbt will load ~/.sbt/1.0/build.sbt as global settings.
commands += Command.command("cls") { state =>
print("\033c")
state
}
Then you can run any commands with cls. For example:
~;cls;compile
~;cls;testOnly

Related

Elixir: VS Code ExUnit cannot find Mix

I cannot load or run my tests, from within VS Code.
I'm a new user to Elixir, and to VS Code. I'm running Lubuntu 21.10 (Impish). I've downloaded Erlang/OTP 25 (.deb), and Elixir 1.14 (precompiled binary in /usr/share/elixir), and can get anything I need running in a Bash terminal. Again, in a standard QTerminal window,
erl, iex, mix, elixir, etc. all work fine.
In VS Code, however, I get some errors. I feel stupid, but I'm coming from Sublime Text, so please forgive me.
In the left pane of VS Code, ExUnit shows an error (red):
Clicking on this error gives me this, on the bottom right pane. The command line options, passed to mix test, seem to be the default configuration:
This result is bizarre to me, because I can open the integrated terminal, execute /bin/sh, and then run the exact mix test line that's displayed:
/usr/share/elixir/bin has been added to my PATH variable, in ~/.bashrc, ~/.profile, and /etc/environment.
However, I am further confused by all tests being excluded, and wonder if there's some connection to the core issue:
Note that I can run my tests just fine, using different command line options. I've tried adding tags, but that didn't fix the problem.
I tried Google'ing this, and played around with my settings. Here is what I have configured in the "User" settings.json, and I made sure nothing overrides this in "Workspace" settings:
Changing the useNativeTesting setting doesn't solve the problem.
On another (?) note, I get a "failed to run elixir" upon VS Code startup:
Again, I have no problem running commands from a Linux terminal, or from a terminal within VS Code.
Plot twist: If I remove the precompiled Elixir 1.14, and downgrade to an older version, via apt, the problem goes away. But Lubuntu 21.10 doesn't offer Elixir 1.14, and I'm really into using the new dbg() feature.
But for now, I cannot load or run my tests, from within VS Code, apparently because Mix cannot be found.
Thanks to Daniel Imms, from the VS Code team, for answering my question on Twitter:
"Try moving where ever you init mix and elixir (.bashrc?) into your .bash_profile and then logging out and in again or restarting. I'm guessing it's in your bashrc which doesn't run in non-interactive sessions like in tasks."

eclipse: how to debug a Scala program called from a shell script

I have a Scala program that is triggered from a shell script. I'd like to be able to run the program in eclipse in debug mode. Anybody knows how that can be done?
Thanks.
I'm not sure if there is a way to debug both together, but what you can do is run your script with the option -xv. So...
user#mypc$: bash -xv myscript other_args
That will show you the commands that are executed along with their parameters.
Then in Eclipse you can debug your Scala program normally and pass those parameters to it through the main method or run configuration.
Typically debuggers are language specific and won't be able to do both bash scripts and code in another language, but with this method, you should be able to figure out what's going on.

i really would like sbt and its console to work under cygwin any way you think it can be done?

i have this issue (https://github.com/sbt/sbt/issues/562)
basically when I try to get a console it says:
[ERROR] Failed to construct terminal; falling back to unsupportedjava.lang.IllegalArgumentException: Invalid terminal type: jline.UnixTerminal
also you cant use backspace
you basically cannot use sbt in cygwin (in dos is fine but cygwin is a much nicer environment)
and have voiced my concern there
i have tried several workaround i found on the net but they are all for old releases and no use now
was just wondering if you know of any workaround?
thanks
The following works for me (mostly, see note at bottom):
Use the mintty shell. I believe this is the default shell for new cygwin installs but has been included as an alternative for a while. If mintty.exe exists in your <cygwin home>\bin folder then it's ready to use, else it can be installed through the typical cygwin package selection from the setup.exe.
Open a mintty window, right click anywhere, go to Options... -> Keys, and make sure Send Backspace as ^H is checked. This will allow the REPL to correctly interpret backspaces.
For just running the Scala REPL that should be all you need, but attempting to run sbt console can still produce that exception. To get past that, run sbt without any arguments to get to the sbt prompt. From there execute:
eval System.setProperty("jline.terminal", "scala.tools.jline.UnixTerminal")
then
console
or, as a single command (with both semi-colons being important):
; eval System.setProperty("jline.terminal", "scala.tools.jline.UnixTerminal") ; console
From what I can tell, this is caused at least in part by the Scala REPL and the sbt prompt using incompatible versions of JLine. In particular, it looks like the Scala REPL created their own wrappers around the library and are using that while sbt is using the JLine library directly.
Note
One limitation that I continue to run into is that the REPL wraps at column 80 even if the shell window has more horizontal space. Not only that, but when the REPL wraps like this it overwrites the same line rather than advancing to the next, and pulling long lines from history ends up pushing the cursor above the line you're actually editing.

eclipse debug perl curses

I am writing a Perl program that uses curses for output and move the cursor, and color characters. Previously, when I was working under windows I use Komodo it was able to run an external console.
Now I work in Linux environment and use eclipse + epic. If you try to just run the script, it uses the internal console eclipse, which is very cut. You can just run the script using external tool, but I'm interested to debug using external console window. Is this possible?
Unfortunately, use of a File and /dev/pty/1 does not help in solving my problem.
The fact is that in this case it is impossible to get the characters introduced in the console through curses getch(). Always returned 1 instead code of pressed key.
Here is an answer that will take you most of the way (based on post #6 of: http://ubuntuforums.org/showthread.php?t=743131, although since then, in the "Indigo" and "Juno" versions of Eclipse, things have changed somewhat, and this answer is up to date):
Go to "Run -> Debug configurations". Click on the (fourth) "Common" tab. Go to the third frame from top, and there, check-mark the checkbox which says: "File". Enter the file name of the console window you want your output in.

eclipse plugin: run command in console, get stdin

I'm making an eclipse plugin where I want to run a system command, and have the output of the command go to the eclipse console. I know how to do this via http://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_from_a_plug-in%3F
The problem I don't know how to solve, is to allow interactive input from the console for this command.
In essence, I want to kick off a command which runs in the console. The user can interact with this command (via stdin). I then want my plugin code to get a callback when the command has finished (or user has manually stopped/terminated the command in the console). Getting the return code of the completed program would be nice as well.
For simplicity sake, lets use the unix 'passwd' command as the example (this is the first common cmd I could think of that both has output and prompts for input). I don't need to hide the stdin however.
For reference, the command I'm trying to call is the CakePHP bake shell.
I assume that you got yourself a MessageConsole, like in the FAQ. Then it should be possible to use messageConsole.getInputStream().read() in a loop to get your input (but I have not tested this). See also the documentation of the IOConsoleInputStream for more options.
On the other hand I'm not sure why you are creating your own plugin to do that. The standard console implementation in Eclipse does exactly what you want. You can see that by running a small Java application, where you can use that console for input and output as well.