Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text string filter (--filter) can't filter using strings that contain a comma #31

Closed
rdmarsh opened this issue Sep 4, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@rdmarsh
Copy link
Owner

rdmarsh commented Sep 4, 2023

Describe the bug
It is not possible to filter (-F/--filter) using a comma in the filter string.

To Reproduce
Steps to reproduce the behavior:

  1. Run any filer using -F/--filter that contains a comma.

Expected behavior
Be able to filter on fields that contain a comma.

Screenshots

$ elm DeviceList -F displayName~test,
Usage: elm DeviceList [OPTIONS]

Error: Invalid value for '--filter' / '-F': format must be 'FIELD[>:,<:,>,<,!:,:,~,!~]VALUE'

$ elm DeviceList -F displayName~test\,
Usage: elm DeviceList [OPTIONS]

Error: Invalid value for '--filter' / '-F': format must be 'FIELD[>:,<:,>,<,!:,:,~,!~]VALUE'

$ elm DeviceList -F "displayName~test\,"
Usage: elm DeviceList [OPTIONS]

Error: Invalid value for '--filter' / '-F': format must be 'FIELD[>:,<:,>,<,!:,:,~,!~]VALUE'

$ elm DeviceList -F "displayName~test,"
Usage: elm DeviceList [OPTIONS]

Error: Invalid value for '--filter' / '-F': format must be 'FIELD[>:,<:,>,<,!:,:,~,!~]VALUE'

$ elm DeviceList -F 'displayName~test,'
Usage: elm DeviceList [OPTIONS]

Error: Invalid value for '--filter' / '-F': format must be 'FIELD[>:,<:,>,<,!:,:,~,!~]VALUE'

$ elm DeviceList -F 'displayName~test,,'
Usage: elm DeviceList [OPTIONS]

Error: Invalid value for '--filter' / '-F': format must be 'FIELD[>:,<:,>,<,!:,:,~,!~]VALUE'

$ elm DeviceList -F 'displayName~test\\,'
Usage: elm DeviceList [OPTIONS]

Error: Invalid value for '--filter' / '-F': format must be 'FIELD[>:,<:,>,<,!:,:,~,!~]VALUE'

$ elm DeviceList -F 'displayName~test\\\,'
Usage: elm DeviceList [OPTIONS]

Error: Invalid value for '--filter' / '-F': format must be 'FIELD[>:,<:,>,<,!:,:,~,!~]VALUE'

Desktop (please complete the following information):

  • OS: Mac 13.5.1 (22G90)
  • Shell: GNU bash, version 5.2.15(1)-release (aarch64-apple-darwin22.1.0)
@rdmarsh rdmarsh self-assigned this Sep 4, 2023
@rdmarsh rdmarsh added the bug Something isn't working label Sep 4, 2023
@rdmarsh
Copy link
Owner Author

rdmarsh commented Sep 5, 2023

Regex will be something like:

for filter in re.split(r'(?<!,),', filters):

@rdmarsh
Copy link
Owner Author

rdmarsh commented Sep 5, 2023

+        #split filters by commas except if they're proceeded by a backslash
+        for filter in re.split(r'[^\\],', filters):
+            #now remove the backslash we used to protect the comma from split above
+            filter = filter.replace('\\,',',')

@rdmarsh
Copy link
Owner Author

rdmarsh commented Sep 5, 2023

Closing, resolved with commit b34d743

@rdmarsh rdmarsh closed this as completed Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant