Adding subcommand completions for launchctl #3682

Merged
merged 1 commit into from Dec 28, 2016

Conversation

Projects
None yet
2 participants
@samdmarshall
Contributor

samdmarshall commented Dec 28, 2016

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Dec 28, 2016

Member

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!

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!

@faho faho added this to the fish 2.5.0 milestone Dec 28, 2016

@samdmarshall

This comment has been minimized.

Show comment
Hide comment
@samdmarshall

samdmarshall Dec 28, 2016

Contributor

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)?

Contributor

samdmarshall commented Dec 28, 2016

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

This comment has been minimized.

Show comment
Hide comment
@faho

faho Dec 28, 2016

Member

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>
'
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>
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment