Description of problem:
- quit;: ScriptException: "quit" is not defined
- return;: ScriptException: invalid return (when in the body of the script)
- return;: works when in a function, but how do you get it to completely exit if the result of the current function is an error or a scenario to quit
- throw("text");: works, but I don't want to show a stack trace to my users
Version-Release number of selected component (if applicable):
Everytime - in the documentation
Steps to Reproduce:
1. Go to http://docs.redhat.com/docs/en-US/JBoss_Operations_Network/2.4/html-single/CLI_Guide/index.html
2. Find section "4.1. Creating the Script"
No definition of usage()
Would like to see the code in the usage() function
I am pretty certain that this example was originally on the RHQ wiki -- but I can't find it there. The only community procedure I see like this is on the jboss.org wiki:
Which references this section in the 2.3 docs (which does *not* contain the usage() thing):
So, I don't have a clue what usage() is doing.
Sanda, do you know 1) what the usage() function is doing in this example and 2) if this is the right function to use?
I will try to track down that script, but I am almost certain it is a function defined within that script. There is no usage function or API of which I am aware that we support.
If I understand the bug description correctly, Nabeel is asking for a way to terminate a script other than throwing an exception. This can be accomplished simply by calling java.lang.System.exit which takes an integer argument.
For more information about regarding integration with the underlying Java platform, take a look at the docs at http://www.mozilla.org/rhino/doc.html.
Lastly, it would be great if questions like these could be directed to the rhq mailing lists and/or the community forums so that they reach a wider audience.
Created attachment 529002 [details]
copy of script referenced in the bug
I believe that this is the script being referenced. Please note that I did not write this script so I may not be able to answer all questions about it. You will find that the script does define a usage function.
I just checked and the RHQ CLI does provide a quit command from the interactive shell, but I am almost certain that the quit command is not available in non-interactive mode. Please feel free to file a separate bug for that if you would like to see that added. Until then, you can use java.lang.System.exit as I stated previously.
Thank you John, yes I believe the java.lang.System.exit should provide what's needed.
I did also find that by creating functions within my JS scripts, I could have them do a "return" and then handle things from there so that I do not throw errors, but informative text with steps to fix the problem.
Many thanks, you can feel free to close this bug. Is there any way the script that you attached can be added into some example files provided with JON or somehow referenced in the docs or put in the docs as an appendix, I prove it can be quite useful for people starting out.
*** Bug 744004 has been marked as a duplicate of this bug. ***
Hopefully, this is clarified in the intro to the chapter here:
Bulk closing of BZs that have no target version set, but which are ON_QA for more than a year and thus are in production for a long time.