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
Add completion for port #4737
Add completion for port #4737
Conversation
end | ||
end | ||
# Remove trailing whitespace and pipe into cache file | ||
port echo all | awk '{$1=$1};1' >$cache_file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will block until the cache file is filled, so it might be worth running this in the background. That means you don't get completions on the first use, but that's better than hanging waiting for a slow command - see what the other approaches taken here are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made some further suggestions below.
share/completions/port.fish
Outdated
return 0 | ||
end | ||
|
||
function __fish_port_use_package --description 'Test if port command should have packages as potential completion' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just use the __fish_seen_subcommand_from
function here.
share/completions/port.fish
Outdated
@@ -0,0 +1,115 @@ | |||
#completion for port | |||
|
|||
function __fish_port_no_subcommand --description 'Test if port has yet to be given the subcommand' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the __fish_use_subcommand
function instead of this function.
share/completions/port.fish
Outdated
complete -f -n '__fish_port_no_subcommand' -c port -a 'version' --description 'Print the MacPorts version' | ||
complete -f -n '__fish_port_no_subcommand' -c port -a 'work' --description 'Displays the path to the work directory for portname' | ||
|
||
complete -c apt-get -s v --description 'Verbose mode, generates verbose messages' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these apt-get entries be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The options and descriptions are correct, but the command should be port, not apt-get. I used apt-get completions as a template, seems to be a relic from that.
share/completions/port.fish
Outdated
|
||
complete -c port -n '__fish_port_use_package' -a '(__fish_print_packages)' --description 'Package' | ||
|
||
complete -f -n '__fish_port_no_subcommand' -c port -a 'activate' --description 'Set the status of an previously installed version of a port to active' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if the description text here comes from the manual page, but it might be better to use shorter and more active voiced descriptions: eg "Activate a previously-installed port". This comment applies to many of the descriptions below - more than 50 or so characters will generally be truncated on smaller screens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, those are taken from the respective manpages. I'll try and shorten the more verbose descriptions.
share/completions/port.fish
Outdated
complete -f -n '__fish_port_no_subcommand' -c port -a 'rev-upgrade' --description 'Manually check for broken binaries and rebuild ports containing broken binaries' | ||
complete -f -n '__fish_port_no_subcommand' -c port -a 'search' --description 'Search for a port using keywords' | ||
complete -f -n '__fish_port_no_subcommand' -c port -a 'select' --description 'For a given group, selects a version to be the default by creating appropriate symbolic links' | ||
complete -f -n '__fish_port_no_subcommand' -c port -a 'selfupdate' --description 'Upgrade MacPorts itself and update the port definition files.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No period (.) needed.
share/completions/port.fish
Outdated
complete -f -n '__fish_port_no_subcommand' -c port -a 'test' --description 'Run test phase of a port' | ||
complete -f -n '__fish_port_no_subcommand' -c port -a 'unarchive' --description 'Extract the destroot of the given ports from a binary archive' | ||
complete -f -n '__fish_port_no_subcommand' -c port -a 'uninstall' --description 'Remove a previously installed port' | ||
complete -f -n '__fish_port_no_subcommand' -c port -a 'unload' --description 'A shortcut to launchctl, like load, but unloads the daemon' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be "unload the daemon" - a similar change can be made to the load
description.
end | ||
# Remove trailing whitespace and pipe into cache file | ||
printf "all\ncurrent\nactive\ninactive\ninstalled\nuninstalled\noutdated" >$cache_file | ||
port echo all | awk '{$1=$1};1' >>$cache_file & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one.
Ok, valid points. I changed all descriptions longer than 50 characters and made some descriptions clearer. My custom commands are gone and I use |
Is there anything else I should change before you can merge this request? The only change requested GitHub still lists is just you commenting 'nice one' on my change of |
No, that looks good to me! |
Description
Adds completion for the MacPorts package manager for macOS. All subcommands and options listed in the port manfile have been added. The package list is generated with the adapted
__fish_print_packages
function. Because port is rather slow, I included cashing. The BSD commands for accessing file age are vastly different from the linux implementation, thus my approach to checking age differs from all others in__fish_print_packages
.TODOs: