Skip to content

Commit

Permalink
Issue#520: add --user and --group to parseApplicationCriteriaArgs pro…
Browse files Browse the repository at this point in the history
…cedure (second attempt)
  • Loading branch information
jdechard committed Jan 22, 2024
1 parent 221c1b2 commit 7a3ac8a
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions tcl/mfcmd.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ proc __parseDateTimeArg {opt datetime} {

# parse application criteria arguments and determine if command applies
proc parseApplicationCriteriaArgs {aftbef nearsec args} {
set flag {}
set otherargs {}

# parse argument list
Expand Down Expand Up @@ -279,15 +278,13 @@ proc parseApplicationCriteriaArgs {aftbef nearsec args} {
}
}
--not-group - --not-user {
set flag 0
if {[getState is_win]} {
knerror "Option '$arg' not supported on Windows platform"
} else {
set nextargisval not[string range $arg 6 end]list
}
}
--group - --user {
set flag 1
if {[getState is_win]} {
knerror "Option '$arg' not supported on Windows platform"
} else {
Expand Down Expand Up @@ -324,29 +321,22 @@ proc parseApplicationCriteriaArgs {aftbef nearsec args} {
set isafter [expr {[info exists after] && [getState clock_seconds] >=\
$after}]

# extract boolean expression according to used argument (driven by $flag)
if {$flag == 0} {
# are criteria met
set apply [expr {!$notuser && !$notgroup && ($isbefore || $isafter ||\
(![info exists before] && ![info exists after]))}]

# is end limit near ?
set isnearly [expr {!$apply && !$notuser && !$notgroup && [info exists\
after] && !$isafter && [getState clock_seconds] >= ($after - $nearsec)}]
if {![info exists afterraw]} {
set afterraw {}
}
} else {
# are criteria met
set apply [expr {$user || $group && ($isbefore || $isafter ||\
(![info exists before] && ![info exists after]))}]

# is end limit near ?
set isnearly [expr {!$apply && $user || $group && [info exists\
after] && !$isafter && [getState clock_seconds] >= ($after - $nearsec)}]
if {![info exists afterraw]} {
set afterraw {}
}
set user_or_group_target_defined [expr {[info exists user] || [info exists\
group]}]
set user_or_group_targeted [expr {$user || $group}]
set user_or_group_excluded [expr {$notuser || $notgroup}]
set time_frame_defined [expr {[info exists before] || [info exists after]}]
set in_time_frame [expr {!$time_frame_defined || $isbefore || $isafter}]

set apply [expr {$in_time_frame && ($user_or_group_targeted ||\
(!$user_or_group_target_defined && !$user_or_group_excluded))}]

# is end limit near ?
set isnearly [expr {!$apply && !$notuser && !$notgroup && $user && $group\
[info exists after] && !$isafter &&\
[getState clock_seconds] >= ($after - $nearsec)}]
if {![info exists afterraw]} {
set afterraw {}
}

return [list $apply $isnearly $afterraw $otherargs]
Expand Down

0 comments on commit 7a3ac8a

Please sign in to comment.