在 Objective-C 中编写一个命令行工具,它接受输入、清除屏幕然后输出
我希望我在这里没有要求太多。
我想创建一个将在终端窗口中运行的命令行工具。它将从终端获取输入,对字符串执行某些操作,清除屏幕,然后输出字符串。
#import <Foundation/Foundation.h>
#include <stdlib.h>
int main (int argc, const char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"Running....");
// take the argument as an NSString
// do something with the NSString.
// clear the terminal screen.
// output the manipulated screen.
[pool drain];
return 0;
}
这可能吗?有什么建议吗?我希望尽可能多地用 Objective-C 来编码。
谢谢,
编辑1*
需要明确的是,我想从程序中不断输入和输出。换句话说,在可执行文件开始运行后需要输入数据。不仅仅是在它最初执行时。
I hope I'm not asking for too much here.
I would like to create a command-line tool that will run in a terminal window. It will take input from the terminal, do something with the string, clear the screen and then output strings.
#import <Foundation/Foundation.h>
#include <stdlib.h>
int main (int argc, const char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"Running....");
// take the argument as an NSString
// do something with the NSString.
// clear the terminal screen.
// output the manipulated screen.
[pool drain];
return 0;
}
Is this possible? Any tips? I would like to be coding this as much as possible in Objective-C.
Thanks,
EDIT 1*
Just to be clear, I would like to be continuously inputting and outputting from the program. In other words, it would be necessary to enter data after the executable has started running. Not just when it initially executes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是可能的。创建项目时,使用 Xcode 中的“命令行工具”模板。
一个简单的例子可能是:
This is possible. Use the "Command Line Tool" template in Xcode when you create your project.
A quick example could be: