Writing GUI frontend for commandline application in Mac OS X

后端 未结 2 1378
轮回少年
轮回少年 2021-01-02 09:49

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?

Spe

2条回答
  •  清酒与你
    2021-01-02 10:42

    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
    

提交回复
热议问题