Skip to content

Content version search filter improvements #226

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

Merged
merged 2 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,11 @@ The following are some examples of how publishers might use the
By default, the `rsconnect content search` command will return metadata for ALL
of the content on a RStudio Connect server, both published and unpublished content.

> **Note:** When using the `--r-version` and `--py-version` flags, users should
> make sure to quote the arguments to avoid conflicting with your shell. For
> example, bash would interpret `--py-version >3.0.0` as a shell redirect because of the
> unquoted `>` character.

```bash
# return only published content
$ rsconnect content search --published
Expand Down
2 changes: 1 addition & 1 deletion rsconnect/actions_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def do_filter(item):
return compare == 1
elif version_filter.comp == "<":
return compare == -1
elif version_filter.comp == "==":
elif version_filter.comp in ["=", "=="]:
return compare == 0
elif version_filter.comp == "<=":
return compare <= 0
Expand Down
8 changes: 6 additions & 2 deletions rsconnect/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from click import ParamType
from click.types import StringParamType

_version_search_pattern = r"(^[=><]{1,2})(.*)"
_version_search_pattern = r"(^[=><]{0,2})(.*)"
_content_guid_pattern = r"([^,]*),?(.*)"


Expand Down Expand Up @@ -310,7 +310,11 @@ def convert(self, value, param, ctx):
version_search.comp = m.group(1)
version_search.vers = m.group(2)

if version_search.comp in ["<<", "<>", "><", ">>", "=<", "=>", "="]:
# default to == if no comparator was provided
if not version_search.comp:
version_search.comp = "=="

if version_search.comp not in [">", "<", ">=", "<=", "=", "=="]:
self.fail("Failed to parse verison filter: %s is not a valid comparitor" % version_search.comp)

try:
Expand Down