Writing GUI frontend for commandline application i

2020-02-28 05:44发布

I am wondering if there is a source of information on how to develop a GUI frontend application for a commandline one in Mac OS X in, but not necessarily, Xcode?

Specifically, I would love a GUI frontend that lets me specify arguments to pass to the commandline program.

Thank you very much.

2条回答
Melony?
2楼-- · 2020-02-28 06:13

You have several options. One of the most commonly used programs to create GUI "front ends" to a script is Platypus. However, this does not allow the user to pass arguments like you want. The other option is creating a Cocoa application and using the NSTask class to run your script with arguments that the user specifies in an NSTextField or NSTokenField. In your case, I think creating a full Cocoa application written in Objective-C is overkill.

The most simple way to get what you want and still have it easy is to create a script written in AppleScript. This is a bare bones script that would do the trick:

display dialog "Enter arguments:" default answer "" buttons {"Cancel", "Run"} default button 2
set scriptArguments to text returned of result
do shell script "/path/to/script " & scriptArguments
查看更多
混吃等死
3楼-- · 2020-02-28 06:29
登录 后发表回答