We typically write our commands so that when no hyphen is present, it is ok to show user interface like a dialog and when a hyphen is present, show command line options. It isn’t a rule, but it is how all of the other commands in Rhino act.
Thank you! That is exactly what I was looking for : )
Thank you as well!
I wanted to do exactly the opposite…
I am working on a common lisp interpreter for Rhino. I called it “RhinoLisp”.
My Idea was as follows:
When started the first time, “RhinoLisp” asks for a file to interpret. The file path is stored and following calls of the command use the same file. This is nice as the file can be edited and then reevaluated just by hitting the space key…
When the user wants to change the file, he uses the “-RhinoLisp” and a file dialog is opened to select a new file.
Unfortunately this seems not to be in accordance with your usage of hyphenated commands then…
Any better ideas how to achieve a similar effect?
Maybe two different commands are better?
Using “RhinoLisp” as common prefix, or
RunLispScript (…which would be inline with RunScript and RunPythonScript) and
OpenAndRunLispScript (…which is a little too verbose for my taste)
When you run “-RhinoLisp”, you should prompt the user for a filename string using a CRhinoGetString object. As part of prompting for a string, you might want to add a “Browse” command line option. By picking Browse, you could then display a file dialog.
For an example of this, launch Rhino and run “-Save”. Notice the “Browse” option…
I would create a “RunLispScript” and use CRhinoGetString to get input in the dashed version as @dale suggests. The string that is returned could either be a path or the entire script. This would allow the script to be embedded in a toolbar button. The non-dashed version could show a file dialog box.
I would also create a “RunPreviousLispScript” to do what you were thinking of for repeating the previous script.
This is just my initial guess; I’m sure users may have alternate opinions once they have something to play with. Looking forward to seeing your work.
ECL makes it easy to extend the functionality in common lisp or C++, whatever is faster or handier. Unfortunately the common lisp wrappers have to be coded mostly by hand. This could be seen as a feature as well, as ECL’s mixed programming style encourages a flexible approach to scripting and the creation of domain-specific languages. Also it is possible to optimize scripts by implementing critical parts in C++. But it also adds an extra level of complexity and it would be nice to be able to automatically generate default wrappers as well : )
By the way, how is the .NET bridge to C++ implemented? By hand? Do you generate it automatically?
There is no method in RhinoScript that will tell you whether or not the last executed command, called with the RunScript method, was executed in scripted (hyphenated) or interactive (non-hyphenated) mode. It is be possible to add something that would report this. Why would you need this?
I would like to allow users to access options, but not have to always go through the extra step in command line each time they run the command. Sort of like the behavior of Rhino’s Fullscreen command and its hyphenated version…
As with Fullscreen, running the non-hyphenated command simply performs the action of going fullscreen. But when using the hyphenated -Fullscreen, you will get a set of options before going fullscreen… The goal is to avoid going through a step of options if someone wants to use it in a pre-determined manner…