nextcloud / nextcloud/server

Future of autocomplete for OCC commands

Open
#63,793 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature: occ technical debt
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

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. https://github.com/nextcloud/server/blob/d8e8703796abb20487e2c4edf6b18b9deaf161a1/apps/dav/lib/Command/ClearCalendarUnshares.php#L49-L53 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Symfony Console usage in linked pull request #62942, the draft user/group completion work in #63792, and the existing Base command completion overrides. Read the OCC autocompletion documentation page to understand the current guidance. Done requires an agreed migration and deprecation direction, updated documentation, and a clearly scoped plan for reusable completion APIs.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, symfony
Domain
cli, developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.