Skip to content

Commit

Permalink
Change --filter to --find (#4087)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSquires authored Jan 24, 2025
1 parent e5769ba commit 9cab054
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion changes/cd12a6feba9161fe9651a4e3bf00bb04.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
desc: Added ``--filter`` option to ``auth.perms.list`` to easily filter permission
desc: Added ``--find`` option to ``auth.perms.list`` to easily filter permission
results.
prs: []
type: feat
Expand Down
14 changes: 7 additions & 7 deletions synapse/lib/stormlib/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,20 +584,20 @@
'name': 'auth.perms.list',
'descr': 'Display a list of the current permissions defined within the Cortex.',
'cmdargs': (
('--filter', {'type': 'str', 'help': 'A search string for filtering permissions.'}),
('--find', {'type': 'str', 'help': 'A search string for permissions.'}),
),
'storm': '''
for $pdef in $lib.auth.getPermDefs() {
$perm = $lib.str.join(".", $pdef.perm)
if $cmdopts.filter {
$filter = $cmdopts.filter.lower()
if $cmdopts.find {
$find = $cmdopts.find.lower()
$match = (
$perm.lower().find($filter) != (null) or
$pdef.desc.lower().find($filter) != (null) or
$pdef.gate.lower().find($filter) != (null) or
($pdef.ex and $pdef.ex.lower().find($filter) != (null))
$perm.lower().find($find) != (null) or
$pdef.desc.lower().find($find) != (null) or
$pdef.gate.lower().find($find) != (null) or
($pdef.ex and $pdef.ex.lower().find($find) != (null))
)
if (not $match) { continue }
Expand Down
4 changes: 2 additions & 2 deletions synapse/tests/test_lib_stormlib_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ async def test_stormlib_auth(self):
self.stormIsInPrint('Controls access to add a new view including forks.', msgs)
self.stormIsInPrint('default: false', msgs)

msgs = await core.stormlist('auth.perms.list --filter macro.')
msgs = await core.stormlist('auth.perms.list --find macro.')
self.stormIsInPrint('storm.macro.add', msgs)
self.stormIsInPrint('storm.macro.admin', msgs)
self.stormIsInPrint('storm.macro.edit', msgs)
self.stormNotInPrint('node.add.<form>', msgs)

msgs = await core.stormlist('auth.perms.list --filter url')
msgs = await core.stormlist('auth.perms.list --find url')
self.stormIsInPrint('storm.lib.telepath.open.<scheme>', msgs)
self.stormIsInPrint('Controls the ability to open a telepath URL with a specific URI scheme.', msgs)
self.stormNotInPrint('node.add.<form>', msgs)
Expand Down

0 comments on commit 9cab054

Please sign in to comment.