Skip to content

Future of autocomplete for OCC commands #63793

Description

@nickvergessen
  • It's quite obvious that we are going to stick with symfony/console going forward and Command API in OCP #62942 is already bringing more direct usage.

Until now stecman/symfony-console-completion

Since a long time we are shipping https://github.com/stecman/symfony-console-completion to help with autocompletion of commands, arguments and options.

We have 53 commands overwriting completeArgumentValues from the Base command in the "managed" apps.

Future native symfony

However since symfony/console 6.4 there is a new autocomplete built-in directly.
Instead of a completion function on the command, you give one on each argument or option.
My idea now would be that we officially deprecate the old style (we can continue to ship the classes so they don't break existing apps if missing).

The documentation should also be adjusted:
https://docs.nextcloud.com/server/latest/admin_manual/occ_command.html#enabling-autocompletion

The only downside I noticed is that the current tool allows to give a program name, which basically allows to autocomplete on aliases for occ out of the box, while on symfony one must manually edit the last line of the output, but that can also be documented

Easy of use for developers

Since it's much easier now, I'd also suggest that we add OCPs for some wide spread completes, which apps can then easily refer to by OCP\Command\Completion::completeUserId(...) and things a like. Most valuable completes are:

Follow-up idea: Enforce completion

A way to remind devs to use autocomplete. Maybe psalm check or something could be written that forces completion to be defined, at least for some well known options/arguments like user/uid/userid/group/gid/groupid/…
Why? Because there is no reason why e.g.

$this->addArgument(
'uid',
InputArgument::REQUIRED,
'User whose unshares to clear'
);
should not assist the admin to autocomplete the user, especially when it's only about adding suggestedValues: Completion::completeUserId(...) going forward.

Request for comments

From anyone providing commands and @CarlSchwan @come-nc @ChristophWurst

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status
    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions