2011-08-31 50 views
1

我有一堆shell腳本和可執行文件,我想將其包裝到Mac的獨立.app包中。我還需要向用戶顯示一個輸入對話框,以便我可以獲取一個值並將其用作我的一個shell腳本的輸入。我需要爲Mac創建一個.app包還有哪些替代方案?

我注意到的Automator允許你創建一個獨立的應用程序,並輸入對話框添加到工作流,但它不是我清楚如何:

  • 包括內我的可執行文件的.app包
  • 添加「運行shell腳本」行動時,指定相對路徑,因此,當用戶雙擊了的.app

在另一方面,我發現我可以執行我的可執行文件,它解釋瞭如何將單個bash腳本轉換爲可點擊的.app。很好,但我仍然需要輸入對話框位。

哪些替代方法需要創建符合上述要求的.app文件?

回答

0

你可以appify把它包起來的。應用程序包,並有腳本本身顯示輸入通過的AppleScript與osascript命令對話框:

ans="$(osascript -e 'Tell application "System Events" to activate' \ 
    -e 'Tell application "System Events" to display dialog "What?" default answer "Fugeddaboutit" buttons {"Yup", "Nope", "Cancel"} default button 1' \ 
    -e '(button returned of result) & ":" & (text returned of result)' 2>/dev/null)" 

if [[ $? -ne 0 ]]; then 
    echo "You cancelled!" 
else 
    echo "You entered '${ans#*:}', and pushed the ${ans%%:*} button." 
fi 
相關問題