Make custom commands

A custom command created with an Extension allows a developer to create a command that can:

  • combine the functionality of one or more standard p4 commands

  • call one or more triggers

  • add custom logic

Such commands resemble native P4 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.

Create 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.

Call your custom command

To call your custom command, use this syntax:

p4 extension --run instName [extArguments]

For example,

p4 extension --run jobinfo-instance joblist