[jboss-jira] [JBoss JIRA] (WFCORE-4481) CLI control flow improvements

Kabir Khan (Jira) issues at jboss.org
Wed May 22 04:38:00 EDT 2019


Kabir Khan created WFCORE-4481:
----------------------------------

             Summary: CLI control flow improvements
                 Key: WFCORE-4481
                 URL: https://issues.jboss.org/browse/WFCORE-4481
             Project: WildFly Core
          Issue Type: Bug
          Components: CLI
            Reporter: Kabir Khan
            Assignee: Jean Francois Denise


Working on CLI script for the OpenShift images, I have found numerous limitations in the CLI control flow functionality. I am opening one issue just to record this, if work ever happens on this I think doing whatever as possible as separate (groups of) RFEs is reasonable.

The limitations in order of preference
*Support if/else-if*
At the moment it seems you can only do if/else. On its own this is not very useful, it would also need implementing of 'Combine expressions being tested for' or 'Support nested control structures' 

*Combine expressions being tested for*
E.g I can do {{if (outcome == success && result=in-memory) of /subsystem=batch-jberet:read-attribute(name=default-job-repository)}}. It would be good to be able to combine more than one of these along the lines of
{code}
if ((outcome == success) of /subsystem=batch-jberet:read-attribute(name=default-job-repository)) && ((result == 123) of /other=resource:read-attribute(name=some-attr))
{code}

*Support nested control structures
At the moment you can only have one level of each of if/for/try. For example the following is allowed:
{code}
for child in /some=resource:read-children-names(child-type=type)
    if (result == []) of /some=resource/type=\$child:read-children-names(child-type=some-type)
      try
         #do something
      end-try
   end-if
done
{code}
But I cannot do:
{code}
if (outcome == success) of /some=resource:read-resource
   if (outcome == success) of /some=resource/child=thing:read-resource
     # do something
   end-if
end-if
{code}
The same goes for for and try.

*Variables*
CLI allows you to use `set` to assign a variable. However, apart from substitution into paths and attribute values they are not very useful. It would be nice to be able to use them in if/for statements. It would also be nice to store the results of reads. Something along the lines of
{code}
set (myvar=result && outcome==success) of /some=resource:read-attribute(name=attr-name)
if ($myvar==https)
   # do something
else if ($myvar==http)
   # do something else
else
   # another thing to do
end-if
{code}

*Array support*

I have
{code}
   for serverName in /subsystem=undertow:read-children-names(child-type=server)
    if (result == []) of /subsystem=undertow/server=\$serverName:read-children-names(child-type=https-listener)
{code}
But I am only able to check if the result is empty. I can't check if it for example contains the string 'https' as one of the entry. Also, apart from being empty we don't really have a way to know the length.




--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the jboss-jira mailing list