wiki:ShellCommands

A typical use case for parameter passing is passing one or more file names as command-line arguments. We want to make that easy for many tools and add appropriate error checking.

To do this, we will extend the existing invoke_app command to handles the following syntax:

invoke_app ... -C <command> ?-C <command> ...? ?-C <command>?
  Tries to find a <command> template that matches a set of parameters
  and executes that command.  Each <command> can contain embedded
  references to parameters:
    @@type(name) ... parameter with the specified type and name
    @@type(#N) ..... parameter with the specified type and position #N on the command line

  The parameter type can be either "file" or "directory".  (More types may be added later.)

Examples

    invoke_app "$@" -C 'firefox @@file(url)' -C 'firefox'

If there's a file parameter named url, then run firefox with that as an argument. Otherwise, run firefox with no arguments.

    invoke_app "$@" -C 'tkdiff @@file(#1) @@file(#2)' -C 'gedit @@file(#1)'

If there are two file parameters, then run "tkdiff" on the two files. Otherwise, run "gedit" with one file. There is no default command (with no parameters), so there must be at least one file parameter or the tool will throw an error.

Errors

If a matching command can be found and there are no other errors, then the command is executed and that's that. But if there are no matching commands, then toolparams shows an error dialog in the tool session. If there are subtle errors (such as extra parameters that are not used in the command template), then toolparams pops up a smaller window in the lower-right corner with error messages.

No image "toolparams.png" attached to ShellCommands

initial implementation: File(toolparams.tcl)?

Last modified 10 years ago Last modified on Jan 22, 2014 1:17:48 PM