Using Extensions to make custom commands

A custom command made with an Extension allows the developer to create a new, single command that might:

  • combine the functionality of one or more standard p4 commands

  • call one or more triggers

  • add custom logic

Such commands resemble native Helix Core commands in that they can have tagged output, send RPC-level messages, and open forms client-side. However, custom commands are restricted to reporting output and cannot access client-side content.

Creating your custom command

You use an Extension to create a custom command. The Lua code in main.lua must include function RunCommand(args)

The RunCommand(args) function:

  • contains the logic for the custom command

  • requires one or more arguments that come from p4 extension --run

  • can return one or two booleans:

    • the first boolean, if true, means success

    • the second boolean, if present and true, indicates that the command should be forwarded to the commit server. By default, if the p4 extension --run command is called on a replica, the command is handled on that replica, and is not forwarded to the commit server.

Calling your custom command

To call your custom command, use this syntax: p4 extension --run instName [extArguments]

For example, p4 extension --run jobinfo-instance joblist