[ 
https://issues.apache.org/jira/browse/TINKERPOP-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15262445#comment-15262445
 ] 

stephen mallette commented on TINKERPOP-1268:
---------------------------------------------

I have some basics for this working now. First, here's {{-i}} in action where a 
script error fails the init but the console stays open. Note how the error now 
shows the line number it stopped at:

{code}
$ bin/gremlin.sh -i init.groovy
         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
Invalid line in init.groovy at [3: z = y + xx] - No such property: xx for 
class: groovysh_evaluate
gremlin> x
==>2
{code}

Same script with {{-e}} goes right to error with no other output because of 
{{-q}} (for quiet output):

{code}
$ bin/gremlin.sh -q -e init.groovy
Invalid line in init.groovy at [3: z = y + xx] - No such property: xx for 
class: groovysh_evaluate
{code}

I then get rid of the bad error in my script and just make it:

{code}
x = 2
y = x + 1
z = y + x 
println z
{code}

and with {{-e}} we get:

{code}
$ bin/gremlin.sh -q -e init.groovy
5
{code}

and with {{-i}} we get:

{code}
$ bin/gremlin.sh -i init.groovy
         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
5
gremlin> x
==>2
gremlin> y
==>3
gremlin> z
==>5
gremlin> 
{code}

I also still support the {{args}} option on a script as we had before with 
{{-e}} so you can also do:  {{bin/gremlin.sh -e script.groovy 1 2 3 4}} and 
have {{1,2,3,4}} folded into a list of {{args}} that are accessible in the 
script. Ultimately I think we might want to get rid of that and simply support 
multiple scripts (like {{bin/gremlin.sh -e script1.groovy script2.groovy, 
...}}), but that's a pretty big breaking change so perhaps that is for later 
discussion.

> Improve script execution options for console
> --------------------------------------------
>
>                 Key: TINKERPOP-1268
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1268
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: console
>    Affects Versions: 3.1.2-incubating
>            Reporter: stephen mallette
>            Assignee: stephen mallette
>              Labels: breaking
>             Fix For: 3.2.1
>
>
> Given the discussion here:
> https://pony-poc.apache.org/thread.html/Zhsn1tow4012xpm
> Implement the following:
> 1. Deprecate support for {{ScriptExecutor}}
> 2. Deprecate support of bin/gremlin.sh init.groovy
> 3. Add support for {{bin/gremlin.sh -i init.groovy}} which does the same 
> thing as (2) and does not exit the console on failure. That would allow a 
> user to work with their console session up to the point of failure.
> 4. Improve support for {{bin/gremlin.sh -e exec.groovy}} to no longer use 
> {{ScriptExecutor}} and execute scripts directly in the console for automation 
> purposes. 
> 5. Add some other options to control output to the console so that you could 
> do {{bin/gremlin.sh -q -e exec.groovy}} which would execute in a quiet mode 
> with no output, for example.
> The idea would be to try to implement this without breaking change.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to