Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 2 (modified by landauf, 16 years ago) (diff)

ArgumentCompleter

TracNav(TracNav/TOC_Development)?

Description

The ArgumentCompleter returns a list of possible arguments for a ConsoleCommand. This is achieved by calling a function which returns an ArgumentCompletionList. These functions are defined in ArgumentCompletionFunctions.

An ArgumentCompleter can be assigned to every argument of a ConsoleCommand:

SetConsoleCommand(ClassName, functionname, bShortcut)
  .argumentCompleter(param-nr (0-4), autocompletion::ac_function());

ac_function is one of the defined functions in ArgumentCompletionFunctions. If the given ConsoleCommand is typed into the Shell? and complete() is called in the CommandExecutor, a list of the possible arguments is displayed in the Shell.

The returned list may depend on the already given set of arguments (including the currently typed argument). This allows to return, for example, all config-values? of a given class, where the classname is the first argument and the name of the config-value the second argument.

Examples

  • Classnames:
    SCC(...).argumentCompleter(0, autocompletion::classnames());
    
    > command-name a
    

In this example the ArgumentCompleter returns a list of all classnames starting with "a".

  • Config-values:
    SCC(...).argumentCompleter(0, autocompletion::configvalueclasses())
            .argumentCompleter(1, autocompletion::configvalues());
    
    > command-name classname b
    

Now the ArgumentCompleter gets called with "classname" and "b" and returns a list of all config-values of "classname" starting with "b".

  • Filesystem:
    SCC(...).argumentCompleter(0, autocompletion::files());
    
    > command-name ./directory/c
    

In this example, the ArgumentCompleter gets called with "./directory/c" and returns a list of files in the directory "./directory" starting with "c"