Jump to content


Broker: Handling multiple flags per command

broker multiple flags regex

  • Please log in to reply
5 replies to this topic

#1 Miles O'Neal

Miles O'Neal

    Advanced Member

  • Members
  • PipPipPip
  • 86 posts

Posted 20 July 2018 - 07:28 PM

The broker docs say:

# The general syntax is:
#
# command: <regex pattern>
# {
#    # Conditions for the command to meet (optional)
#    # Note that with the exception of 'flags', these are regex patterns.

Why are flags excepted?

Is there a way to handle multiple flags in one command scope? Or to negate a flag (as in anything but this flag)?

I know I can have multiple handlers for the same command, one flag per instance, but blargh.[1]

Thanks!

[1] A highly technical term. If you don't understand it, you don't want to know.

#2 p4rfong

p4rfong

    Advanced Member

  • Staff Moderators
  • 293 posts

Posted 20 August 2018 - 06:21 PM

You can put in an entry for each flag.  For example, for conditions -a and -m

command: opened
{
    flags    = -a;
    action   = filter;
    execute = /home/rfong/perforce/openeda.sh;
}

command: opened
{
    flags    = -m;
    action   = filter;
    execute = /home/rfong/perforce/openedm.sh;
}

Otherwise, customize your filter script to handle the conditions you are looking for.

#3 Miles O'Neal

Miles O'Neal

    Advanced Member

  • Members
  • PipPipPip
  • 86 posts

Posted 12 September 2018 - 09:12 PM

Thanks, I know. That's what I'm doing now, but it's silly to have multiple, identical command sections just to handle multiple flags. Do we know the rationale behind this? Is there any reason that flags can't be handled like anything else? It seems like it should be an easy change. Thanks!

#4 p4rfong

p4rfong

    Advanced Member

  • Staff Moderators
  • 293 posts

Posted 13 September 2018 - 07:43 PM

Try a command trigger such as
    usercmd command pre-user-user "/home/perforce/usercmd.sh %user% %argsQuoted%"

#!/bin/bash
#     usercmd command pre-user-user "/home/perforce/usercmd.sh %user% %argsQuoted%"
echo "Running usercmd.sh"
echo "User is $1 %args% is $2"
if [ "$1" == "rfongA" ]; then
    echo "User $1 not allowed to run p4 user.  Exiting."
    exit 1
fi

This results in:

$ p4 user -o -f rfong
Running usercmd.sh
User is rfong %args% is -o,-f,rfong
# A Perforce User Specification.
#
<snip>

Note this shows multiple arguments.

#5 Miles O'Neal

Miles O'Neal

    Advanced Member

  • Members
  • PipPipPip
  • 86 posts

Posted 17 September 2018 - 03:46 PM

I appreciate these suggestions; I have thought of them (and am already doing one). I'm just asking why the broker doesn't let us do this. It seems an odd limitation.

#6 p4rfong

p4rfong

    Advanced Member

  • Staff Moderators
  • 293 posts

Posted 18 September 2018 - 01:23 AM

Most of the broker functionality is in the command trigger, so resources were available for the P4Broker.





Also tagged with one or more of these keywords: broker, multiple, flags, regex

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users