-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
56 lines (40 loc) · 1.99 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Process Command is a library to use Native Process API from AIR2.
The library allow you to use command with process, to use it like a service.
Pre requirements:
Using AIR2
changing application descriptor with <supportedProfiles>extendedDesktop</supportedProfiles>
Example:
create a Native Process service and initialize it:
public var procService:NativeProcessService;
public var startCommand:INativeProcessCommand;
public function init():void{
procService = new NativeProcessService();
if(procService.isMacOs){
procService.initialize(macAppName,macAppPath);
}else if(procService.isWindows){
procService.initialize(winAppName,winAppPath);
}else{ //is linux...
procService.initialize(linuxAppName,linuxAppPath);
}
procService.IOInputError.add(onIOInputError); //listener with IOErrorEvent param
procService.IOOutputError.add(onIOOutputError); //listener with IOErrorEvent param
}
Running an application or starting a listening application without arguments and listening for activities
startCommand = procService.start();
startCommand.output.add(onOutput); //listener with data:ByteArray
startCommand.error.add(onError); //listener with data:ByteArray
startCommand.exit.add(onExit); //listener with data:Object containing outputData (ByteArray) and errorData (ByteArray)
Create a Command and execute it
var cmd:NativeProcessCommand = new NativeProcessCommand();
cmd.commandName = nameOfCommand; //(e.g for git: init)
cmd.args.addItem(otherParam); //you can add as much as you need
cmd.output.add(onCmdOutput); //listener with data:ByteArray
cmd.error.add(onCmdError); //listener with data:ByteArray
cmd.exit.add(onCmdExit); //listener with data:Object containing outputData (ByteArray) and errorData (ByteArray)
//if the process is not running
//you can specify the working directory
cmd.workingDirectory = File.applicationDirectory
//and running the command
procService.runCommand(cmd);
//if the process is running, inject the command
procService.injectCommand(cmd);