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: try to complete copy or command #585

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

Conversation

martinetd
Copy link
Collaborator

When using clush -c we should try to complete local files.

When not using -c, if a taget has already been set we can also try to complete a command.
We could do like ssh and try to complete it on any node in the nodeset, but a local completion is probably good enough.

And still complete possible options but only do so if a dash was present, this is similar to what e.g. ls completion does

Fixes #584

@thiell thiell added this to the 1.9.4 milestone Feb 23, 2025
@martinetd martinetd force-pushed the completions_files_commands branch from fbb660e to 915c1b7 Compare March 1, 2025 13:27
@kcgthb
Copy link
Contributor

kcgthb commented Mar 3, 2025

Thanks for the fix!

I know I'm being a nitpicker here, but two more minor details :)

  1. nodeset/group completion works for short options only if there's a space after the option. For instance:

    • clush -w@ log<TAB> completes to clush -w@ login as expected
    • but clush -w@log<TAB> doesn't completes to anything (although -w@login is a valid syntax
  2. command completion only works when it's placed before filename completion. But if -c happens first in the command line, then command completion doesn't work anymore. For instance, this doesn't complete the nodeset:

    $ clush -c /etc/slurm/slurm.conf -w @log<TAB>
    

When using clush -c we should try to complete local files.

When not using -c, if a taget has already been set we can also try to
complete a command.
We could do like ssh and try to complete it on any node in the nodeset,
but a local completion is probably good enough.

And still complete possible options but only do so if a dash was
present, this is similar to what e.g. `ls` completion does

Fixes cea-hpc#584
@martinetd
Copy link
Collaborator Author

  1. is unrelated to this PR, opened completion: handle short opts without spaces #586
  2. fixed

In either case, we allow options to be way too complex... WTH does clush -c file1 -w nodes file2 even work?!

Oh, combining the two patches clush -c<tab> doesn't properly complete file names from the start of the files; I'm tempted to say I don't care enough so just skipping... (as this involves standard bash-completion helpers, while we can lie about $cur I don't know how to re-add the -c prefix at the start of completions... So you won't be able to strip that space down, sorry :P)
Ah, while I'm on weird stuff things like -vwnode also doesn't work. I'll also leave that one as an exercise to the reader...

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.9.3: File path completion in copy mode
3 participants