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

completion: handle , in node list #575

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

martinetd
Copy link
Collaborator

Split when multiple words are given to properly find matching nodes or groups:

  • get last partial nodeset
  • complete as if that was the current argument
  • then re-add the prefix for compword to match

==========

This is a bit too ugly for my taste so I tried doing the handling in cluset --complete, something like this is a start:

+        # --completion "$cur" (optional groups to complete)
+        if len(args) < 1:
+            return
+        cur_arg = args[0]
+        # try to get the last "word" from 'cur', for union/intersection:
+        # remove anything that doesn't contain a [, or contain both [ and ]
+        match = re.match(r'([^,[]*(\[[^]]*])?[,&])*(.*)', cur_arg)
+        if match:
+            cur = match.group(3)
+            prefix = cur_arg.removesuffix(cur)
+        else:
+            cur = cur_arg
+            prefix = ''

but even if we have this, it's printing completion suggestions through regular list and expand commands so we cannot really pre-match/add prefix as I would have liked to do, so here we are :/

Happy to say 1.9.3 gets completion only on first word, and we can work this through later if someone feels the need to...
When using node names directly with different prefixes it is rather handy (e.g. clush -w foo1,bar3,moo4) but I don't think that's a major usecase.

Split when multiple words are given to properly find matching nodes or
groups:
- get last partial nodeset
- complete as if that was the current argument
- then re-add the prefix for compword to match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant