社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Git

如何在Swift中从macOS应用程序运行git命令?

Kevin Machado • 5 年前 • 1780 次点击  

我想运行一个git命令,然后从macOS应用程序启动Xcode。

但我现在在第一步就被阻止了: 运行git命令

Process , NSWorkspace.shared.openApplication 但我还是被挡住了。你可以在这里看到我最后一次尝试。

@discardableResult
func shell(_ app: String, _ args: String...) -> Int32 {
    let task = Process()
    task.launchPath = "/usr/bin/\(app)"
    task.arguments = args
    task.launch()
    task.waitUntilExit()
    return task.terminationStatus
}

shell("git", "clone https://github.com/user/repo.git")

git:'克隆 https://github.com/user/repo.git '不是git命令。请参阅“git--help”。

我需要授予权限吗?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/55452
 
1780 次点击  
文章 [ 1 ]  |  最新文章 5 年前
Code-Apprentice
Reply   •   1 楼
Code-Apprentice    5 年前

你在向 git "clone https://github.com/user/repo.git" . 相反,您需要将“clone”和URL作为单独的参数传递:

shell("git", "clone", "https://github.com/user/repo.git")