ClientApi::Run( const char *, ClientUser * )

Run a Helix Server command and return when it completes.

Virtual?

No

 

Class

ClientApi

 

Arguments

const char *func

the name of the command to run

 

ClientUser *ui

a pointer to a ClientUser object

Returns

void

 

Notes

The func argument to Run() is the Helix Server command to run, (for instance, info or files). Command arguments are not included and must be set separately with StrDict::SetArgv().

Initialize the connection with Init() before calling Run(), because without a connection, no commands can be sent to the server. Attempting to call Run() before Init() will probably result in a fatal runtime error.

Run() returns only after the command completes. Note that all necessary calls to ClientUser methods are made during the execution of Run(), as dictated by the server.

Tip

For managing the network connection of the run, relevant Helix Core Server configurables are:

Example

The code below runs p4 info, using ClientUser::OutputInfo() to display the results to the user. If a subclass of ClientUser is used here as the ui argument, that subclass’s implementation of OutputInfo() is used to display the results of the command.

ClientApi client;
ClientUser ui;
Error e;

client.Init( &e );
client.Run( "info", &ui );
client.Final( &e );