从终端,我可以调用所有Salesforce DX CLI命令和功能。例如," sfdx force:doc:commands:list"将显示所有命令。但是从Mac上的NSTask代码(下面),我根本无法调用Salesforce DX CLI。 terminationStatus标志为true。其他命令如" ls"工作得很好。这是因为路径吗?权限?提前谢谢......
ptr portcommandlineinterface(char *thecommand)
{
ptr theptr;
NSTask *task;
NSPipe *pipe;
NSData *data;
NSFileHandle *file;
NSArray *arguments;
int thesize, status;
const char *junkptr;
NSString *string, *tempstring;
tempstring = [NSString stringWithUTF8String:thecommand];
if (tempstring == 0) return(0);
task = [[NSTask alloc] init];
[task setLaunchPath: @"/bin/sh"];
[task setCurrentDirectoryPath: @"~"];
arguments = [NSArray arrayWithObjects: @"-c", tempstring, nil];
[task setArguments: arguments];
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
file = [pipe fileHandleForReading];
[task launch];
[task waitUntilExit];
status = [task terminationStatus];
if (status) return(0);
data = [file readDataToEndOfFile];
string = [[NSString alloc] initWithData: data encoding:NSUTF8StringEncoding];
junkptr = [string UTF8String];
thesize = cstrlen((char *)junkptr);
theptr = portnewptr(thesize + 10);
cstrcpy((char *)junkptr, theptr);
return(theptr);
}