#!/usr/bin/env python
#==============================================================================
# Copyright and license info is available in the LICENSE file included with
# the Server Deployment Package (SDP), and also available online:
# https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE
#------------------------------------------------------------------------------
#
# This is command trigger to allow you to block commands from all but listed users. 
#
# Trigger table entry examples:
# command-block command pre-user-obliterate "/p4/common/bin/triggers/command_block.py %user%"
# command-block command pre-user-(obliterate|protect$) "/p4/common/bin/triggers/command_block.py %user%"

import sys

passusers = [ 'perforce' ]
user=sys.argv[1]

if user in passusers:
  sys.exit(0)
else:
  print("You are not allowed to run this command.")
  sys.exit(1)
