Future of autocomplete for OCC commands
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
- It's quite obvious that we are going to stick with symfony/console going forward and https://github.com/nextcloud/server/pull/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:
- user id
- group id
I started a draft in https://github.com/nextcloud/server/pull/63792 - maybe also team id?
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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