Skip to content

Improve xe-cli completion #6524

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 5 commits into from
Jun 12, 2025

Conversation

last-genius
Copy link
Contributor

Handle a few more cases, fix logging, reduce slowdown

…ions

While one could potentially filter for this "value", I don't think it's that
useful and adds noise to the completions, like here:

```
$ xe vm-list resident-on=
64c11cad-2c52-4dea-aea6-5fae0e720699
\<not\ in\ database\>
7f566729-0ee7-47c4-853d-2c5f3a195ad4
```

Signed-off-by: Andrii Sultanov <[email protected]>
log needs to be moved one line below the first assignment into the
"description" variable, otherwise it's always going to be an empty string

Signed-off-by: Andrii Sultanov <[email protected]>
@@ -784,7 +784,8 @@ __preprocess_suggestions()
{
wordlist=$( echo "$1" | \
sed -re 's/(^|[^\])((\\\\)*),,*/\1\2\n/g' -e 's/\\,/,/g' -e 's/\\\\/\\/g' | \
sed -e 's/ *$//')
sed -e 's/ *$//' | \
sort | uniq )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be echo | sed -e ... -e ... | sort -u to remove two processes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I include sed -e 's/ *$//' into the previous sed invocation, it no longer strips whitespace for some reason...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because -r (extended regex) applies to the whole sed invocation. One of the two -e's need rewriting to use the other regex form.

We used to rely on Bash's completion removing duplicate entries from the
suggestions, but processing them in the first place is unnecessary (and will
slow down completion since there's usually an 'xe' command run for each entry
in the wordlist).

Signed-off-by: Andrii Sultanov <[email protected]>
Provide a helpful description for some parameters of 'xe vm-list', compare
before:
```
$ xe vm-list resident-on=
64c11cad-2c52-4dea-aea6-5fae0e720699
7f566729-0ee7-47c4-853d-2c5f3a195ad4
```

with after:
```
$ xe vm-list resident-on=
64c11cad-2c52-4dea-aea6-5fae0e720699  - hpmc30
7f566729-0ee7-47c4-853d-2c5f3a195ad4  - hpmc29
```

Signed-off-by: Andrii Sultanov <[email protected]>
No completion was provided before, and it's handled properly now:
```
$ xe vm-list suspend-SR-uuid=
08906228-cbf6-dad4-720d-e581df11510a  - SR1
37b734f0-e594-0e48-2114-cd063241dd36  - SR2
```

Signed-off-by: Andrii Sultanov <[email protected]>
@last-genius last-genius force-pushed the asv/improve-completion branch from e79d89d to 2a8e55b Compare June 11, 2025 14:27
@last-genius last-genius added this pull request to the merge queue Jun 12, 2025
Merged via the queue into xapi-project:master with commit 3ceb3d2 Jun 12, 2025
16 checks passed
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.

4 participants