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

Adding subcommand completions for launchctl #3682

Merged
merged 1 commit into from
Dec 28, 2016

Conversation

samdmarshall
Copy link
Contributor

Description

Adding subcommand completions for launchctl in the same manner that gem has. I don't know if additional things need to be done so this doesn't get populated for systems that don't have launchctl (non-os x systems).

Is there a way to auto-generate subcommand completions for subcommands? It only seemed to work for command line flags (- or --).

TODOs:

  • Changes to fish usage are reflected in user documenation/manpages.
  • Tests have been added for regressions fixed

@faho faho merged commit 4cd3481 into fish-shell:master Dec 28, 2016
@faho
Copy link
Member

faho commented Dec 28, 2016

I don't know if additional things need to be done so this doesn't get populated for systems that don't have launchctl (non-os x systems).

Completions are autoloaded, so there's no issue there. The worst that'll happen is that people get completions for a command they don't have.

Is there a way to auto-generate subcommand completions for subcommands? It only seemed to work for command line flags (- or --).

Unfortunately no, because there's no real standard parsable format for how they should be mentioned in man pages.

I see this adds subcommands via something like xa 'bootstrap\t"'(_ "Bootstraps a domain or a service into a domain")'"'. This isn't too pretty, but probably the best way to offer localization. That's something we should probably take more seriously in general (heck, I should go and check the german one).

__fish_use_subcommand is a very simple function - it assumes any bare (i.e. not starting with "-") token is a subcommand. From the man page, this seems to be okay, since there are no options whatsoever to launchctl in general (and especially none that take arguments, which would break with __fish_use_subcommand.

Long story short: Merged, thanks!

@samdmarshall
Copy link
Contributor Author

Compared to the "regular" flag-based completions, these seem to be a bit of a hack/magic to get working. Any chance that this could be addressed as an enhancement to the complete function to add proper support for subcommands (as many Ruby and Python based tools use subcommands rather than flags)?

@faho
Copy link
Member

faho commented Dec 28, 2016

The long-term plan is #478 - replacing the current completion system with something based on docopt. From #478 (comment) and @ridiculousfish's following comments, the syntax would be something like

complete --signature '
    Usage:
        ip link show <device>
        ip addr [add | del] <ifaddr> dev <devname>
        ip route [ add | del | change | append | replace | monitor ] <route>
'

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
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

2 participants