[ 
https://issues.apache.org/jira/browse/FELIX-1487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12743837#action_12743837
 ] 

Derek Baum commented on FELIX-1487:
-----------------------------------

gogo already supports commands spanning multiple lines:

The problem is that you need to add semicolons at the end of  each statement, 
which is not simply at the end of each line:

bundles = [
  org.cauldron.newton.osgi.util
  org.cauldron.newton.log-service
  org.cauldron.newton.config
];

each $bundles {
  echo starting bundle $it;
  start  $it;
}

Although this seems easy enough, it is not.
Even when I had a working script, when I changed it to add a single line I 
would always forget to add the semicolon.

The solution I used didn't involve changing the runtime.

My method responsible for reading a script into a string (so it can be passed 
to CommandSession.execute()),
also transforms the script if it begins with a #:

1. lines beginning with # are treated as comments
2. lines NOT ending in \ automatically have a semicolon appended

So the above script would become:

# script
bundles = [ \
  org.cauldron.newton.osgi.util \
  org.cauldron.newton.log-service \
  org.cauldron.newton.config \
]

each $bundles { \
  echo starting bundle $it
  start  $it
}

You now have to add a backslash to any line that you don't want a semicolon to 
be appended to.
In practice this is relatively few lines, compared to the number that would 
require a semicolon.


An alternative would be to change the parser to treat newline as a statement 
separator like in Scalar.
This would be good too, but probably better left until Gogo has its own 
parser-generator.





> Support for commands on multiple lines
> --------------------------------------
>
>                 Key: FELIX-1487
>                 URL: https://issues.apache.org/jira/browse/FELIX-1487
>             Project: Felix
>          Issue Type: Improvement
>          Components: Gogo
>            Reporter: Guillaume Nodet
>
> I think this is important, especially when writing closures, to be able to 
> split commands on multiple lines.
> From the shell, it can't be easily leveraged, unless the command line edition 
> also supports multiline edition, but for script files, it would be really 
> handy.
> My original thinking would be to consider new lines as ';', but this may 
> required changing the precedence order of | and ;
> The other solution would be add a pseudo grouping operator () on each line in 
> addition to considering newlines as ';'

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to