Giter VIP home page Giter VIP logo

bshconsole's People

Contributors

nickl- avatar stefanofornari avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

nickl-

bshconsole's Issues

Static method normalizeClassName(Class) not found in class'bsh.StringUtil' when printing an array

bsh # a  = {10, 20};
ret1: [I@27dc2c75
--> $4 = {10I, 20I} :int[]
bsh # print($4);
Unknown error: java.util.concurrent.ExecutionException: bsh.EvalError: Error in method invocation: Static method normalizeClassName(Class) not found in class'bsh.StringUtil' : at Line: 29 : in file: /bsh/commands/print.bsh : StringUtil .normalizeClassName ( arg .getClass ( ) ) 

Called from method: print/BlockNameSpace : at Line: 1 : in file: <unknown file> : print ( $4 ) 

Status update - 20180825

BshConsole v1.2.0 has been released, you can find it here.

What's new

  • Added a command cls() to clear the terminal's screen

Other changes

  • fixed issue #21 - TokenMgrException on ^C
  • improved messages on ^C, ^D, ^Z

Console magix... looks promising

I been wanting to try jline... wasn't so much fun =/ I'm thinking that maybe jline3 is not quite there. Groovy as well as jShell seem to be using jline2 so maybe that is the better option. see jline/jline2 What do you think?

I really made a mess of things so not worth trying to roll a PR. Here are some things I worked out.

Sets the history file for persistence:

    lineReader.setVariable(
        LineReader.HISTORY_FILE,
        new File(System.getenv("HOME")+"/.bsh-console.hist"));

I added it just after lineReader build()

The only way I got the shell to react as expected is by using bsh.CommandLineReader interpreter input reader. It is package private but I'm sure we can make some accessor for it. It's the only way I seem to get a prompt back after pressing return on a blank line.

Interpreter bsh = new Interpreter(
    new CommandLineReader( new InputStreamReader(IN)),
    System.out, 
    System.err,
    true);

There are new methods available through Reflect for getting to the namespace variables and methods.

Reflect.getVariableNames(bsh.getNameSpace());
Reflect.getMethodNames(bsh.getNameSpace());

And then from there you can get to the variables via object (instance) or class (static) as well as the namespace

Reflect.getVariable(bsh.getNameSpace(), name);
Reflect.getVariable(object, name);
Reflect.getVariable(type, name);

To get to the class namespace once you have the instance

Reflect.getThisNS(object); // instance namespace
Reflect.getThisNS(type); // static namespace

But no idea where we're supposed to catch the completed name with jline, it just completes, adds the space no way how to prevent that space it even removes anything (like a dot . ) that you try to add after the completed variable name. No where I can find the completed word again it's now forgotten.

Status update - 20180804

BshConsole v1.0.0 is not general available and can be downloaded from maven central here.

A few important note: BshConsole is based on the latest (HEAD/SNAPSHOT) of Beanshell 2.1.0; this has not been released yet and is currently (Aug 4th, 2018) available only building from source as a maven snapshot. This prevented to release a version of BshConsole. To overcome this problem, BshConsole uses a released version of a Beanshell snapshot from the fork https://github.com/stefanofornari/beanshell. You should be able to replace a fresh build of the Beanshell jar into /lib without any problem. If you encounter any issues, please open a ticket.

Next step

  • fix issue #5 (Upgrade to jline 3.8.x ) - DONE
  • Show the version of the beanshell jar used at startup
  • Add status bar at the bottom of the console - DONE
  • Background execution of commands - DONE

^C Cannot interrupt loops

The new modification does not recover from loop interruption and also doesn't stop the loop leaving orphan thread running.

To reproduce

bsh % a = 1;
bsh % while (true) a++;

(...)





Test dependencies still a mess

So issues with the test dependencies.

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/interperon/git/beanshell/BshConsole/BshC/src/test/java/bsh/BugFreeBshConsoleInterpreter.java:[19,28] package ste.xtest.concurrent does not exist
[ERROR] /Users/interperon/git/beanshell/BshConsole/BshC/src/test/java/bsh/BugFreeBshConsoleInterpreter.java:[20,28] package ste.xtest.concurrent does not exist
[ERROR] /Users/interperon/git/beanshell/BshConsole/BshC/src/test/java/bsh/BugFreeBshConsoleInterpreter.java:[72,13] cannot find symbol

Found ste.test xtest 1.20.1-SNAPSHOT again but get compile error.

Could not find artifact ste.web:webtoolkitlib:jar:1.7.2 I have ste.web webtoolkit 1.9.2-SNAPSHOT so lets try that.

BUILD FAILURE
Tests run: 243, Failures: 2, Errors: 0, Skipped: 0

Ok lets try:

mvn install -DskipTest

Got xtest-1.20.1-SNAPSHOT.jar installed. Lets try again.

Now at least no build errors anymore but tests still fail

[ERROR] Failures:
[ERROR]   BugFreeBshConsoleInterpreter.prompt_at_start:72 task expected to complete in 500 milliseconds, but it did not finished in 0 milliseconds
[ERROR]   BugFreeBshConsoleInterpreter.prompt_at_start_failure:97 task expected to complete in 3000 milliseconds, but it did not finished in 0 milliseconds

[ERROR] Tests run: 12, Failures: 2, Errors: 0, Skipped: 1

You really can't expect us to consider the tests if the existing ones don't pass.

Unknown error: java.util.concurrent.ExecutionException even in normal cases

When the execution of a statement fails, it may throw the exception:

Unknown error: java.util.concurrent.ExecutionException: bsh.EvalError: Undefined argument: users : at Line: 1 : in file: : ( users )

This is just because the statement was executed in a asynchronous task and only the root cause should be displayed

^C produces EOF exception

Interrupting multi line now produces EOF exceptions again.

This is fixed in BeanShell upstream...

Welcome to bshell ${version}

bsh #
bsh # class A {

(...)
// Error: Parser Error: In file: <unknown> Encountered <EOF> at line 2, column 9.

bsh #

InterruptedIOException not catched

Similarly to issue #27, when closing the console by typing ^D, we may get the following exception:

Exception in thread "Thread-3" java.io.IOError: java.io.InterruptedIOException: Command interrupted
	at org.jline.terminal.impl.AbstractPosixTerminal.getSize(AbstractPosixTerminal.java:62)
	at org.jline.terminal.Terminal.getWidth(Terminal.java:191)
	at ste.beanshell.JLineConsole.status(JLineConsole.java:81)
	at ste.beanshell.JLineConsole.on(JLineConsole.java:59)
	at bsh.BshConsoleInterpreter.run(BshConsoleInterpreter.java:150)
	at java.lang.Thread.run(Thread.java:748)

We should instead catch it.

TokenMgrException on ^C

bsh # print("
dkjhgdfk
^C

(...)

Unknown error: bsh.TokenMgrException: Lexical error at line 1, column 8.  Encountered: <EOF> after : ""

prompt not correctly working

The prompt is disappearing once deleting all chars of a line.

It resulted to be an issue with the way jline and beanshell manage the prompt and the input.

Eveluation errors not displayed

to reproduce:

bsh # a["10"] = 1;

expected:

// Error: Evaluation Error: Arrays may only be indexed by integer types.: Can't assign String to int : at Line: 2 : in file: : [ "one" ]

actual:
no message displayed

Replace beanshell standard help system with a more extensible help system

I'd like to be able to provide a flexible and simple help system for 3rd party commands or added commands. This is how it should work:

bsh.help shall point to a directory where the help text of the various commands will be stored, one file per command. The help file shall be named [command name].txt and follow the resource conversion of turning package namespaces into subfolders (e.g. help file com/acme/app/show.txt is for command com.acme.app.show).

A new command help() shall be provided. This lists all help files and print them all on the console's output stream. If help() is used with one or more string arguments, the help files of the given commands shall be printed.

bsh.help shall default to /help

This should replace the use of bsh.help. which quite limited in the length and formatting of the text.

current status - 20180705

A first bunch of known issues have been fixed and the console is now ready for prime time.
Basic features are:

  • line editing just as one would expect
  • history
  • tab-completion of vars and functions/methods
  • proper handling of Ctrl+C
  • customization initialization script in scripts/init.bsh read at start-up

TODO:

  1. release a not-snapshot version with distribution package(*)
  2. better tab-completion based on PR #3

(*) I am not sure yet which version of beanshell I can include. It cannot be a snapshot, therefore maybe it will be b06 until a not-snapshot of beanshell is tagged.

Status update - 20180814

BshConsole v1.1.0 has been released, you can find it here.

What's new

  • Added a status bar that shows when the console is reading (READ) or busy executing a command (BUSY)
  • ^Z support: now pressing ^Z when some code is being executed, put the execution in the background in a separate thread. The identifier of the task is displayed in the status bar.

Next step

  • Show the version of the beanshell jar used at startup

Status update - 20181209

BshConsole v1.3.0 has been released, you can find it here.

What's new

  • Implemented a new and more flexible help system (see issue #28)

Other changes

  • fixed issue #24 - Results of last command not properly displayed (since v2.1.1)
  • fixed issue #25 - Status bar get corrupted if too many tasks are running concurrently (since v2.1.1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.