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

Update rsync completions #7763

Merged
merged 7 commits into from Mar 4, 2021
Merged

Update rsync completions #7763

merged 7 commits into from Mar 4, 2021

Conversation

Jakeler
Copy link
Contributor

@Jakeler Jakeler commented Mar 1, 2021

Description

This adds completions for the newer (and very useful) info+debug flags, parsed from the help output:
Screenshot_20210228_220622
Also many other options that were missing. Based on the current rsync 3.2.3 man page.

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

share/completions/rsync.fish Outdated Show resolved Hide resolved
share/completions/rsync.fish Outdated Show resolved Hide resolved
share/completions/rsync.fish Outdated Show resolved Hide resolved
share/completions/rsync.fish Outdated Show resolved Hide resolved
share/completions/rsync.fish Outdated Show resolved Hide resolved
share/completions/rsync.fish Outdated Show resolved Hide resolved
complete -c rsync -l partial -d "Keep partially transferred files"
complete -c rsync -l partial-dir -xa '(__fish_complete_directories)' -d "Put a partially transferred file into DIR"
complete -c rsync -l delay-updates -d "Put all updated files into place at end"
complete -c rsync -s m -l prune-empty-dirs -d "Prune empty directory chains from file-list"
complete -c rsync -l numeric-ids -d "Don’t map uid/gid values by user/group name"
complete -c rsync -l usermap -xa '(__fish_complete_users)' -d "Custom username mapping"
complete -c rsync -l groupmap -xa '(__fish_complete_groups)' -d "Custom username mapping"
complete -c rsync -l chown -xa '(__fish_complete_users;__fish_complete_groups)' -d "Combined username/groupname mapping"
Copy link
Member

Choose a reason for hiding this comment

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

A space after the ; would be nice.

(also this does user:group, so maybe (__fish_complete_users):(__fish_complete_groups) might be helpful, or more complicated logic to only complete the group after the user - see __fish_complete_user_at_hosts for something similar)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(__fish_complete_users):(__fish_complete_groups) unfortunately does not work in my testing, if I type : and hit TAB it removes the whole option? Is there a any simple solution for the common user:group pattern?

Copy link
Member

@faho faho Mar 4, 2021

Choose a reason for hiding this comment

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

Aaaah, okay, both of these provide a description (after a tab character), so only the users part is actually used (because the rest is now after a tab).

Here's what the actual chown completions do:

complete -c chown -d Username -a "(__fish_print_users):"
complete -c chown -d Username -a "(string match -r -- '.*:' (commandline -ct))(__fish_complete_groups)"

You could probably make a helper function that

  1. if you don't have a ":" in the current token (commandline -ct) runs __fish_complete_users
  2. If you do, prints the current token plus everything in __fish_complete_groups

(this would then also be useful in chown, and possibly elsewhere)

Or alternatively we can merge this as it stands and do that bit later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I think it is best to merge as it is and make such a helper function in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

Since :somegroup is valid, that might need a separate entry (untested):
(echo; __fish_print_users):(__fish_complete_groups)

share/completions/rsync.fish Outdated Show resolved Hide resolved
share/completions/rsync.fish Outdated Show resolved Hide resolved
@faho faho added this to the fish 3.2.1 milestone Mar 2, 2021
@faho faho merged commit ece0aa5 into fish-shell:master Mar 4, 2021
@faho
Copy link
Member

faho commented Mar 4, 2021

Merged, thanks!

@Jakeler Jakeler deleted the rsync-compl branch March 15, 2021 23:34
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants