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

ASF GitHub Bot commented on TINKERPOP-1653:
-------------------------------------------

GitHub user spmallette opened a pull request:

    https://github.com/apache/tinkerpop/pull/576

    TINKERPOP-1653 Allow multiple scripts to be passed to gremlin.sh

    https://issues.apache.org/jira/browse/TINKERPOP-1653
    
    This is a non-breaking change and simply allows multiple `-i` and `-e` 
options on gremlin.sh. The old method for passing a single script name to 
gremlin.sh remains intact as well. Had to write a custom parser for the command 
line arguments to do this because it doesn't appear that `CliBuilder` is 
capable of parsing the in the manner necessary to support this feature 
unfortunately.
    
    Here's some example usage given these three scripts:
    
    ```text
    $ more *.groovy
    ::::::::::::::
    x.groovy
    ::::::::::::::
    x = 1 + 1
    ::::::::::::::
    y.groovy
    ::::::::::::::
    y = args.collect{Integer.parseInt(it)}.sum()
    ::::::::::::::
    z.groovy
    ::::::::::::::
    z = "argument=" + args
    ```
    
    This is old, now deprecated, method that is still supported:
    
    ```
    $ bin/gremlin.sh x.groovy 
    
             \,,,/
             (o o)
    -----oOOo-(3)-oOOo-----
    plugin activated: tinkerpop.server
    plugin activated: tinkerpop.utilities
    plugin activated: tinkerpop.tinkergraph
    gremlin> x
    ==>2
    ```
    
    Next with `-i` as usual:
    
    ```text
    $ bin/gremlin.sh -i x.groovy
    
             \,,,/
             (o o)
    -----oOOo-(3)-oOOo-----
    plugin activated: tinkerpop.server
    plugin activated: tinkerpop.utilities
    plugin activated: tinkerpop.tinkergraph
    gremlin> x
    ==>2
    ```
    
    then with arguments:
    
    ```text
    $ bin/gremlin.sh -i y.groovy 1 2 3
    
             \,,,/
             (o o)
    -----oOOo-(3)-oOOo-----
    plugin activated: tinkerpop.server
    plugin activated: tinkerpop.utilities
    plugin activated: tinkerpop.tinkergraph
    gremlin> y
    ==>6
    ```
    
    Next with multiple scripts:
    
    ```text
    $ bin/gremlin.sh -i y.groovy 1 2 3 -i x.groovy
    
             \,,,/
             (o o)
    -----oOOo-(3)-oOOo-----
    plugin activated: tinkerpop.server
    plugin activated: tinkerpop.utilities
    plugin activated: tinkerpop.tinkergraph
    gremlin> y
    ==>6
    gremlin> x
    ==>2
    ```
    
    Then with multiple scripts with other `gremlin.sh` options mixed in
    
    ```text
    $ bin/gremlin.sh -i y.groovy 1 2 3 --color -i x.groovy -i "z.groovy x -i 
--color -D"
    
             \,,,/
             (o o)
    -----oOOo-(3)-oOOo-----
    plugin activated: tinkerpop.server
    plugin activated: tinkerpop.utilities
    plugin activated: tinkerpop.tinkergraph
    gremlin> x
    ==>2
    gremlin> y
    ==>6
    gremlin> z
    ==>argument=[x, -i, --color, -D]
    ```
    
    Finally, note that you still can't mix/match `-i` and `-e` commands - 
`CliBuilder` still rejects bad stuff like that:
    
    ```text
    $ bin/gremlin.sh -i y.groovy 1 2 3 --color -i x.groovy -e "z.groovy x -i 
--color -D"
    -i and -e options are mutually exclusive - provide one or the other
    ```
    
    VOTE +1

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/apache/tinkerpop TINKERPOP-1653

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/tinkerpop/pull/576.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #576
    
----
commit 1503311f030291745276805188e61b525576d604
Author: Stephen Mallette <[email protected]>
Date:   2017-03-17T14:23:34Z

    TINKERPOP-1653 Allow multiple scripts to be passed to gremlin.sh
    
    This is a non-breaking change and simply allows multiple -i and -e options 
on gremlin.sh. The old method for passing a single script name to gremlin.sh 
remains intact as well. Had to write a custom parser for the command line 
arguments to do this because it doesn't appear that CliBuilder is capable of 
parsing the in the manner necessary to support this feature unfortunately.

----


> Allow multiple scripts with arguments to be passed to the Console
> -----------------------------------------------------------------
>
>                 Key: TINKERPOP-1653
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1653
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: console
>    Affects Versions: 3.2.4
>            Reporter: stephen mallette
>            Assignee: stephen mallette
>
> Gremlin Console currently supports {{-e}} and {{-i}} for passing in scripts 
> to execute from the command line, but it is only possible to pass one script 
> with either command. It would be helpful to allow multiple scripts with 
> associated arguments for each as it would provide greater flexibility when 
> doing automation through the console.
> {code}
> bin/gremlin.sh -i scripts/x.groovy -i scripts/y.groovy 123 test -D -i 
> "scripts/z.groovy -D -i -e"
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to