Script management

From GNUstepWiki
Jump to navigation Jump to search

Application and tool specific scripts are stored in Library/StepTalk/Scripts/domain_name directory where domain_name is a name of an application or tool. The place is called script repository and is being accessed by the script manager.

Script repositories

The manager is looking for scripts in:

  • actual application's resource directory (ApplicationName.app/Resources/Scripts)
  • application specific scripts in all GNUstep Library directories (*/Library/StepTalk/Scripts/ApplicationName)
  • shared scriptins in all GNUstep Library directories (*/Library/StepTalk/Scripts/Shared)
  • resource directories of all bundles loaded by the application (BundleName.bundle/Resources/Scripts)

(*) can be any of GNUstep System, Local, Network or user home path

STScriptManager is used to get application or tool specific script by name:

STScriptManager *manager = [STScriptManager defaultManager];
STScript        *script;

script = [manager scriptWithName:@"someScript"];

Script name can be without the file extension.

To execute the script you have to use appropriate engine for language [script language] and execute [script source].

Scripts provided by bundles and frameworks

Bundles and frameworks can also provide scripts for an application or a tool. In addition, script manager will search for scipts also in all loaded bundles and frameworks in bundle_path/Resources/Scripts.

Sharing scripts

Scripts that can be shared between tools and applications are stored in Library/!StepTalk/Scripts/Shared.

If you want to execute a script from another domain, for example, if your application can share scripting interface with some another application, you should get a script manager for that another domain:

STScriptManager *foreignManager = [ [STScriptManager alloc] initWithDomainName:@"AnotherApplication"];

Script Metafile

Each script may have accopmpaining file containing information about script. This information file is optional, has extension .stinfo and its name is script name with that extension. For example if script name is insertDate.st then information file is insertDate.st.stinfo. File may contain:

  • script name that will be shown to the user (localizable)
  • script description (localizable)
  • scripting language used for script -- overrides language guess based on file extension

The file is dictionary property list. Kes are:

Name: Name of a script that is shown to the user.

Description: Description of a script.

Language: Scripting language name used in script. This value overrides language guess based on script file extension.

Example:

   {
       Default = {
           Name = "Some name";
           Description = "Some description";
       };
       English = {
           Name = "Some name in english";
           Description = "Some description in english";
       };
       French = {
           Name = "Some name in french";
           Description = "Some description in french";
       }
   }

See also: StepTalk