< Zurück

16.05.2014 16:23:00 • Categories: Monkey X, 2D Game SDK / Framework, Multiplatform

Monkey-X: Template Command line tool

Import commandlineapp

'summary: This is the command line tool starting point: Function Main() Local tool:= New CommandLineTool() End

'summary: This class handles the launching and parameters of the command line tool Class CommandLineTool Extends CommandLineApp

'summary: This is called when the command line tool launches.
Method New()

    #REM
    Notice there are several field defined in this class, such as assemblyLocation, assemblyName and  parameters.
        - Self.assemblyName contains the name of the tool executable file (IE. the EXE file in windows os)
        - Self.assemblyLocation contains the path in the filesystem where the tool is located.
        - Self.paramters is a string array with any parameter passed to the tool. If no parameter is present, this array is of length zero.
    #END

    'Place the command line tool code here:

End

End

Import brl.filepath
Import os

'summary: This class handles the launching and parameters of the command line tool Class CommandLineApp Abstract

'summary: This field contains the name of this tool assembly. That is, in windows, the EXE file of this tool.
Field assemblyName:String

'summary: This field contains the location in the file system where this tool is stored.
Field assemblyLocation:String

'summary: This array of strings contains all the paramters passed to this command line tool from the terminal or console.&lt;br&gt;If none is passed, this array will be of length zero.
Field parameters:String[]

Method New()

    'this is the tool executable name (on windows, the EXE file name):
    assemblyName = filepath.StripDir(os.AppArgs[0])

    'This is the tool executable path, the folder where the assembly is located:
    assemblyLocation = filepath.ExtractDir(os.AppArgs[0])

    'We get the list of parameters
    parameters = os.AppArgs[1 ..]

End

'summary: Use this method to abruptly end current application.&lt;br&gt;The "success" parameter may be set to true or false depending of the cause of the tool being ended.
Method EndApplication(success:Bool)
    If success Then os.ExitApp(0) Else os.ExitApp(-1)
End

End

 

Quelle: Templates


< Zurück | ^ nach oben