← 返回
开发者工具 中文

p4u

Perforce / Helix Core (p4) power-user CLI. Use for any p4 task: show or inspect changelists (CLs), shelve/unshelve/reshelve, switch between CLs, delete CLs o...
Perforce / Helix Core (p4) 高级用户命令行工具。用于执行各类 p4 任务:查看或检查变更列表 (CL)、搁置/取消搁置/重新搁置、切换变更列表、删除变更列表等。
m9rco
开发者工具 clawhub v0.0.0-nightly.e055304 2 版本 100000 Key: 无需
★ 1
Stars
📥 602
下载
💾 37
安装
2
版本
#latest#nightly

概述

p4u

Single Go binary, zero external dependencies. Wraps common p4 workflows with

colour output, JSON mode, and --non-interactive for automation.

Repo: https://github.com/m9rco/p4u-skill

Binary status

!which p4u 2>/dev/null && echo "✓ $(p4u --version 2>/dev/null || which p4u)" || echo "✗ p4u not found — install required (see Prerequisites below)"

Prerequisites

p4u and p4 must be installed before using this skill.

Install p4u

Download the pre-built binary for your platform from the releases page:

macOS / Linux:

OS=$(uname -s | tr '[:upper:]' '[:lower:]') && ARCH=$(uname -m)
[[ "$ARCH" == "x86_64" ]] && ARCH=amd64 || ARCH=arm64
BASE="https://github.com/m9rco/p4u-skill/releases/download/nightly"
curl -fsSL "${BASE}/p4u-${OS}-${ARCH}" -o /tmp/p4u
curl -fsSL "${BASE}/checksums.txt" -o /tmp/p4u-checksums.txt
# Verify integrity before installing (works on both macOS and Linux)
EXPECTED=$(grep "p4u-${OS}-${ARCH}" /tmp/p4u-checksums.txt | awk '{print $1}')
ACTUAL=$(command -v sha256sum >/dev/null 2>&1 && sha256sum /tmp/p4u | awk '{print $1}' || shasum -a 256 /tmp/p4u | awk '{print $1}')
[ "$EXPECTED" = "$ACTUAL" ] || { echo "Checksum mismatch — aborting"; rm -f /tmp/p4u; exit 1; }
chmod +x /tmp/p4u && sudo mv /tmp/p4u /usr/local/bin/p4u

Windows (PowerShell):

Invoke-WebRequest -Uri "https://github.com/m9rco/p4u-skill/releases/download/nightly/p4u-windows-amd64.exe" `
  -OutFile "$env:USERPROFILE\AppData\Local\Microsoft\WindowsApps\p4u.exe"

Install p4 CLI

macOS (Homebrew):

brew install p4

Linux:

curl -fsSL "https://cdist2.perforce.com/perforce/r24.2/bin.linux26x86_64/p4" \
  -o /tmp/p4 && chmod +x /tmp/p4 && sudo mv /tmp/p4 /usr/local/bin/p4

Windows:

Invoke-WebRequest -Uri "https://cdist2.perforce.com/perforce/r24.2/bin.ntx64/p4.exe" `
  -OutFile "$env:USERPROFILE\AppData\Local\Microsoft\WindowsApps\p4.exe"

Or use the official instructions at: https://www.perforce.com/downloads/helix-command-line-client-p4

Then log in: p4 login

Rules

  1. Check first: run which p4u to verify the binary is installed. If missing,

inform the user and show the install command above — do not execute install

commands autonomously.

  1. Always pass --non-interactive — prevents hanging on prompts.
  2. Destructive operations (delete-client, delete-cl, revert-all, any -f/--force

flag) require explicit user confirmation before running. Show the command and

ask the user to confirm — never execute destructive commands autonomously.

  1. Pass --json when output needs to be parsed programmatically; omit it for

human-readable display.

  1. Changelist numbers are plain integers, e.g. 12345.
  2. p4u auto-reads current user and client from p4 info.
  3. Error handling: on non-zero exit show the raw output as-is; do not silently

retry with different flags.

Workflow Decision Tree

Match the user's intent to the right command — act immediately, no clarifying

questions needed for these standard cases:

User says…Run this
---------------------------------------------------------------------------------------------------
"show my work", "what CLs do I have"p4u show --non-interactive
"switch to CL 12345", "load changelist 12345"p4u switch 12345 --non-interactive
"who changed line N of //depot/…"p4u annotate //depot/… N --non-interactive
"inspect CL 12345", "what's in changelist …"p4u show-cl 12345 --non-interactive
"delete this client", "remove my workspace"confirm first, then p4u delete-client --non-interactive
"find untracked files", "what's not in p4"p4u untracked --non-interactive
"revert everything", "undo all changes"confirm first, then p4u revert-all --non-interactive
"reshelve CL 12345"p4u reshelve 12345 --non-interactive
"unshelve CL 12345"p4u unshelve 12345 --non-interactive
"delete CL 12345"confirm first, then p4u delete-cl 12345 --non-interactive

Workflow Examples

Show my open work

p4u show --non-interactive          # pending + shelved
p4u show -p --non-interactive       # pending only
p4u show -s --non-interactive       # shelved only
p4u show --json --non-interactive   # for further processing

Switch to a different changelist

Shelves current work first, then unshelves the target:

p4u switch 12345 --non-interactive
p4u switch 12345 -s -m --non-interactive   # also sync + auto-resolve
p4u switch 12345 -k --non-interactive      # keep existing shelve

Who changed this line?

p4u annotate //depot/main/src/foo.cpp 42 --non-interactive
p4u annotate -v //depot/main/src/foo.cpp 42 --non-interactive  # verbose
p4u annotate --json //depot/main/src/foo.cpp 42 --non-interactive

Inspect a changelist

p4u show-cl 12345 --non-interactive
p4u show-cl 12345 -b --non-interactive     # brief: no file list
p4u show-cl 12345 --json --non-interactive

Clean up a stale client

p4u delete-client --non-interactive        # uses current client
p4u delete-client -c myclient --non-interactive
p4u delete-client -f --non-interactive     # skip confirmation
p4u delete-client -n --non-interactive     # keep local files

Find untracked files

p4u untracked --non-interactive
p4u untracked ./src ./assets --non-interactive
p4u untracked -d 3 --non-interactive       # max depth 3
p4u untracked --json --non-interactive

Full Command Reference

Show client status

p4u show --non-interactive              # pending + shelved changelists
p4u show -s --non-interactive           # shelved only
p4u show -p --non-interactive           # pending only
p4u show --json --non-interactive       # JSON output
p4u show -u <user> --non-interactive    # filter by user
p4u show -c <client> --non-interactive  # filter by client
p4u show -m 10 --non-interactive        # limit to 10 results

Reshelve / unshelve

p4u reshelve <CL> --non-interactive
p4u unshelve <CL> --non-interactive

Revert all opened files

p4u revert-all --non-interactive

Delete a changelist

p4u delete-cl <CL> --non-interactive
p4u delete-cl -f <CL> --non-interactive   # force, no confirmation
p4u delete-cl <CL1> <CL2> --non-interactive

Global flags

FlagShortDescription
-------------------------------------------------------------
--non-interactiveDisable all interactive prompts
--jsonJSON output
--no-colorDisable colour
--force-colorForce colour when piping

版本历史

共 2 个版本

  • v0.0.0-nightly.e055304 当前
    2026-03-29 17:34 安全 安全
  • v0.0.0-nightly.08b71ba
    2026-03-26 22:25

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 67 📥 180,031
developer-tools

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 921 📥 185,769
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 668 📥 323,998