ControlTier > controltier-core
 

exists

Command Reference

Description

Checks if an object exists

Looks up the object in the specified project depot. Objects are specified by name and type. If a matching object is found, then the value "true" is printed to the console. If the object is not found the value "false" is printed.

If the assert parameter is specified then the command will fail if the stipulated test is not true.

static: This command can be run outside of an object context.

Usage

ctl -m modelutil -c exists [-assert <>] -depot <> -name <> -type <>

Options

Option Description Type Default
assert assert the condition. true or false

Fail the command if the assertion is not met.

  • true: Fail if the object does not exist
  • false: Fail if the object does exist
string
depot project depot name string ${context.depot}
name logical node name string
type the node type string

Examples

Check if the Node object exists. (it does)

ctl -p demo -m modelutil -c exists -- -type Node -name strongbad

returns: true

Check if the Node object exists. (it does not)

ctl -p demo -m modelutil -c exists -- -type Node -name bogushaha

returns: false

The exists command also accepts the assert parameter. This option can take true or false as its argument. It will cause the command to fail if the conditon is not met.

ctl -p demo -m modelutil -c exists -- -type Node -name strongbad -assert true

returns: true

Run the same command but assert that the node does not exist

ctl -p demo -m modelutil -c exists -- -type Node -name strongbad -assert false

returns: Command failed: object does exist

Check if the Node object does not exist. (it does not)

ctl -p demo -m modelutil -c exists -- -type Node -name bogushaha -assert false

returns: false

Check if the Node object does not exist but assert that it should

ctl -p demo -m modelutil -c exists -- -type Node -name bogushaha -assert true

returns: object does not exist