Task Inputs and Results

KosmicTask Help

Task Inputs and Results

A task generally accepts some form of input and often generates a specific result. When a task is executed the input control values are passed to the task script for processing. A result produced by the task is then returned to the user.

KosmicTask provides a number of plug-in based inputs that provide an effective means of providing the inputs to a task. Any number and selection of input types can be defined to provide the input parameters for a given task. The standard input types are:

  • Date. Provides a graphical date selection input.
  • File. Provides a means of selecting the contents of a file as an input. KosmicTask sends the selected file's data to the machine executing the task and provides access to the data via a temporary local path. A task can also return file contents as results.
  • File Path. In contrast to the File input above the file path input provides just the path to the selected file. This is generally only useful when executing tasks on the local machine (as paths referring to files in the user's home folder will not be valid on remote machines) but it may also be used in situations where the file path lies outside of the user's home folder.
  • List Item. Provides a means of selecting an item from a list. The list can be configured with any number of items. This input provides a means of implementing a simple Yes or No type selection.
  • Number. Provides a number input selection between an upper and lower bound with configurable formatting and a variable number of decimal places.
  • Text. Provides a simple textual input to a task and can accept either a single or multiple lines of text.

Task Results

When a task completes it may generate a result that is returned to the user. Task results may consist of simple textual objects such as a date, a string of text or a number. More complex results containing data such as arrays and dictionaries (aka associative arrays or hashes or maps) can also be returned.

Complex results also permit the returning of the contents of a file or files as all or part of a result. Complex results retain their structure when presented to the user and thus can be navigated using an outline controller. More importantly, such results can be saved as external files that maintain the result content and structure. This is especially important when generating results that may be used as inputs to other tasks or imported into other applications for processing.

In addition, CSS based style commands can be embedded in complex results in order to provide result styling.

Complex Task Results

Complex task results are generally returned as YAML formatted strings. YAML (YAML Ain't Markup Language or Yet Another Markup Language) is a straightforward human readable way of representing complex data types containing strings, scalars, arrays and dictionaries. Its simple syntax makes it easy for traditional command line scripting languages like Bash to generate complex results simply by printing YAML formatted strings to their standard output.

YAML is a popular method of representing data relationships and bindings exist for many scripting languages. KosmicTask makes use of these bindings for Java, JavaScript, Perl, Php, Python and Ruby within application defined controller objects. These controller objects handle the translation between the scripts native data structure and YAML. Thus the task produces its result as a native data structure and then passes it over to the controller for formatting. This YAML formatted data is then returned to the user as a structured result.

KosmicTask also supports a number of Cocoa bridges. These bridges allow native language objects to be returned directly as task results without any additional formatting.

Scripting Language Plug-ins

Each supported scripting language is implemented as a separate language plug-in that defines how KosmicTask interacts with the language executable components and may also provide those executable components. A language plug-in can also define additional resources to assist with script building and task control.

Most scripting languages provide some means of validating or compiling a script prior to its execution. This functionality is invoked by KosmicTask whenever a task build is requested. Some languages lack an integrated validation facility and rely on additional external tools. A language plug-in may optionally include such a tool and invoke it during the build stage.

Scripts that run in-process with their task runner normally have access to a KosmicTask supplied controller object. This object is designed to allow the task to communicate directly with the task runner. The controller is generally an object written in the target scripting language. In some cases the task will have to explicitly create a reference to or an instance of the controller object. In other cases the controller object will be pre-defined with the task's scope.

A language plug-in can also provide access to additional scripting facilities.