IntelliJ

42 views
Skip to first unread message

John Dewsnip

unread,
Jun 9, 2014, 2:43:12 PM6/9/14
to crash...@googlegroups.com
Hi,

I have a few questions about running CRaSH as a main in IntelliJ. This is the first time I have run the shell.

1. Is org.crsh.cli.impl.bootstrap.Main the right main to run from IntelliJ?

2. When I run I get the following extra format chars which I am guessing is due incorrect term detection. How do I make them go away?

[1mNAME     [0m DESCRIPTION                                                          
[31mdashboard [0m a monitoring dashboard                                               
[31megrep     [0m search file(s) for lines that match a pattern                        
[31menv       [0m display the term env                                                 
[31mfilter   [0m a filter for a stream of map                                         
[31mjava     [0m various java language commands                                       
[31mjdbc     [0m JDBC connection      

3. I've added extra java based commands and these are on the classpath with the method annotated with @Command. I can't see them in help or run them. What else do I need to do? 

I hope you can help.

Regs.

Julien Viet

unread,
Jun 9, 2014, 3:18:13 PM6/9/14
to crash...@googlegroups.com


Julien Viet
julienviet.com


On Monday 9 June 2014 at 20:43, John Dewsnip wrote:

> Hi,
>
> I have a few questions about running CRaSH as a main in IntelliJ. This is the first time I have run the shell.
>
> 1. Is org.crsh.cli.impl.bootstrap.Main the right main to run from IntelliJ?
likely the most convenient way, never really thought about this use case.
>
> 2. When I run I get the following extra format chars which I am guessing is due incorrect term detection. How do I make them go away?
>
> [1mNAME [0m DESCRIPTION
> [31mdashboard [0m a monitoring dashboard
> [31megrep [0m search file(s) for lines that match a pattern
> [31menv [0m display the term env
> [31mfilter [0m a filter for a stream of map
> [31mjava [0m various java language commands
> [31mjdbc [0m JDBC connection

by having a proper detection of this use case and reconfiguring the console connector to skip the rendering the style objects which would at some point change this class:

https://github.com/crashub/crash/blob/master/shell/src/main/java/org/crsh/console/jline/JLineProcessor.java

and change:

public void write(Style d) throws IOException {
d.writeAnsiTo(writer);
}



to something like:

public void write(Style d) throws IOException {
if (ansi) {
d.writeAnsiTo(writer);
}
}


Same for “cls”.

Can you put a break point in the class https://github.com/crashub/crash/blob/master/shell/src/main/java/org/crsh/standalone/CRaSH.java at line 366 and let us know if ansi detection happens properly in the blocks:

if (!term.isAnsiSupported()) {
out = AnsiConsole.out;
err = AnsiConsole.err;
} else {
out = new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out), 16384), false);
err = new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err), 16384), false);
}



if that works well, then it would be fairly easy to reconfigure the console connector to add a “ansi” option.
>
>
> 3. I've added extra java based commands and these are on the classpath with the method annotated with @Command. I can't see them in help or run them. What else do I need to do?
Two solutions:

1/ you provide the code source .java or .groovy and let CRaSH compile it for you with configuration of the source as a mount point provider. classpath:/crash/commands/ is mounted by default, so having the sources in a package crash/commands would work out of the box. See http://www.crashub.org/beta/reference.html#_mount_point_configuration

2/ implement your own CommandResolver that can return classes and declare it as a CRaSH plugin. This test case does exactly that : https://github.com/crashub/crash/blob/master/shell/src/test/java/org/crsh/shell/impl/command/CustomCommandResolverTestCase.java
>
>
> I hope you can help.
>
> Regs.
>
> --
> Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "CRaSH User Group".
> Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse crash-users...@googlegroups.com (mailto:crash-users...@googlegroups.com).
> Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.



Julien Viet

unread,
Jun 9, 2014, 5:03:25 PM6/9/14
to crash...@googlegroups.com
so I got your scenario working:

1/ so concerning the ansi in Intellij I fixed this issue which allows to run it via system property configuration:

https://jira.exoplatform.org/browse/CRASH-217

This skip ansi escapes in non ansi terminals you need to force the terminal detection to “none” in the system properties with org.crsh.console.jline.terminal set to none.

2/ concerning the detection of commands I used the mount point configuration "classpath:/crash/commands/;file:./src/crash/commands/“

So the Intellij configuration is:

Main class : org.crsh.standalone.CRaSH
VM options : -Dorg.crsh.console.jline.terminal=none
Program arguments : --cmd classpath:/crash/commands/;file:./src/crash/commands/

note that up/down arrows are not supported since this will move the cursor in Intellij.

Julien Viet
julienviet.com


On Monday 9 June 2014 at 21:18, Julien Viet wrote:

>
>
> Julien Viet
> julienviet.com (http://julienviet.com)
Screen Shot 2014-06-09 at 23.02.33.png

John Dewsnip

unread,
Jun 10, 2014, 1:54:18 AM6/10/14
to crash...@googlegroups.com
Hi Julien,

It works great and will save me a lot of time,

Thanks.


--
Vous recevez ce message car vous êtes abonné à un sujet dans le groupe Google Groupes "CRaSH User Group".
Pour vous désabonner de ce sujet, visitez le site https://groups.google.com/d/topic/crash-users/_IVgbu4a-io/unsubscribe.
Pour vous désabonner de ce groupe et de tous ses sujets, envoyez un e-mail à l'adresse crash-users...@googlegroups.com.
Pour plus d'options, visitez le site https://groups.google.com/d/optout .

Julien Viet

unread,
Jun 10, 2014, 4:14:45 AM6/10/14
to crash...@googlegroups.com
you’re welcome, I added a tip in the reference documentation for running in an IDE : https://github.com/crashub/crash/blob/master/doc/reference/src/main/asciidoc/connectors.asciidoc#terminal-detection


Julien Viet
julienviet.com


On Tuesday 10 June 2014 at 07:54, John Dewsnip wrote:

> Hi Julien,
>
> It works great and will save me a lot of time,
>
> Thanks.
>
>
> On 9 June 2014 22:03, Julien Viet <jul...@julienviet.com (mailto:jul...@julienviet.com)> wrote:
> > so I got your scenario working:
> >
> > 1/ so concerning the ansi in Intellij I fixed this issue which allows to run it via system property configuration:
> >
> > https://jira.exoplatform.org/browse/CRASH-217
> >
> > This skip ansi escapes in non ansi terminals you need to force the terminal detection to “none” in the system properties with org.crsh.console.jline.terminal set to none.
> >
> > 2/ concerning the detection of commands I used the mount point configuration "classpath:/crash/commands/;file:./src/crash/commands/“
> >
> > So the Intellij configuration is:
> >
> > Main class : org.crsh.standalone.CRaSH
> > VM options : -Dorg.crsh.console.jline.terminal=none
> > Program arguments : --cmd classpath:/crash/commands/;file:./src/crash/commands/
> >
> > note that up/down arrows are not supported since this will move the cursor in Intellij.
> >
> > Julien Viet
> > julienviet.com (http://julienviet.com)
> >
> >
> > On Monday 9 June 2014 at 21:18, Julien Viet wrote:
> >
> > >
> > >
> > > Julien Viet
> > > julienviet.com (http://julienviet.com) (http://julienviet.com)
> > > > Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse crash-users...@googlegroups.com (mailto:crash-users%2Bunsu...@googlegroups.com) (mailto:crash-users...@googlegroups.com (mailto:crash-users%2Bunsu...@googlegroups.com)).
> > > > Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.
> > >
> >
> >
> >
> > --
> > Vous recevez ce message car vous êtes abonné à un sujet dans le groupe Google Groupes "CRaSH User Group".
> > Pour vous désabonner de ce sujet, visitez le site https://groups.google.com/d/topic/crash-users/_IVgbu4a-io/unsubscribe.
> > Pour vous désabonner de ce groupe et de tous ses sujets, envoyez un e-mail à l'adresse crash-users...@googlegroups.com (mailto:crash-users%2Bunsu...@googlegroups.com).
> > Pour plus d'options, visitez le site https://groups.google.com/d/optout .
>
>
Reply all
Reply to author
Forward
0 new messages