强制 : Is there any command to check if client spec exist or not

标签 perforce perforce-client-spec

实际上我需要编写一个批处理脚本,首先我需要检查所需的客户端规范是否已经存在? 如果存在那么我应该删除它。

如果所需的客户端规范存在或不存在,您能否告诉我们如何 checkin 脚本?

最佳答案

在 Windows 命令行上,你可以执行类似的操作

set P4CLIENT=client-name
p4 clients -e %P4CLIENT% | findstr %P4CLIENT% >nul

p4 client -e %P4CLIENT% 将输出匹配 %P4CLIENT% 的所有客户端。 findstr 将在 p4 客户端 的输出中搜索客户端名称并打印它。重定向到 nul 将抑制此输出,但 findstr 将另外设置 %errorlevel% 变量。

一些例子:

p4 clients -e existing-client | findstr existing-client >nul
echo %errorlevel%

将返回 0。

p4 clients -e does-not-exists | findstr does-not-exists >nul
echo %errorlevel%

将返回 1。

如果您想执行某些操作,如果给定的客户端空间存在,您可以运行以下命令:

p4 clients -e does-not-exists | findstr does-not-exists >nul || create-client.bat

如果你想执行某些操作,如果给定的客户端空间确实存在,你可以运行以下命令:

p4 clients -e does-not-exists | findstr does-not-exists >nul && do-something.bat

感谢来自 perforce 在线聊天支持的 Adam!

关于强制 : Is there any command to check if client spec exist or not,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19631132/

相关文章:

android - 为什么 Android Studio 2.0 不支持 Perforce?

perforce - 如何使用命令行在perforce中移动目录?

version-control - 微软商店中的 Perforce

mercurial - Perforce 与 Mercurial 的客户端规范映射类似

perforce - 如何在 Mac 中设置 Perforce P4LOG 大小

svn - Subversion 选项显示更新结果而不实际更新

perforce - 在 Perforce 中,我如何 checkin 以前在另一台机器/工作区上 checkout 的文件?

perforce - 如何在perforce中删除Stream Depot

perforce - P4PASSWD 无法在 perforce 命令行中工作