Skip to content

Command API in OCP - #62942

Merged
CarlSchwan merged 12 commits into
masterfrom
carl/ocp-console
Aug 11, 2026
Merged

Command API in OCP#62942
CarlSchwan merged 12 commits into
masterfrom
carl/ocp-console

Conversation

@CarlSchwan

@CarlSchwan CarlSchwan commented Aug 5, 2026

Copy link
Copy Markdown
Member

Summary

Inspired by the new API from symfony/console

This will allow us to remove all our ugly stubs in many apps.

Can be used either on a class:

#[AsCommand(
     name: 'app:create-user',
     // this short description is shown when running "occ list"
     description: 'Creates a new user.',
     // this is shown when running the command with the "--help" option
     help: 'This command allows you to create a user...',
     // this allows you to show one or more usage examples (no need to add the command name)
     usages: ['bob', 'alice --as-admin'],
)]
class CreateUserCommand {
    public function __invoke(
        #[Argument(description: "The username of the user")] string $userId,
        IOutput $output,
    ): ExitCode {
        // ...
        return ExitCode::Success;
    }
}

Or on methods:

class UserCommands {
    #[AsCommand('app:user:create')]
    public function create(
        #[Argument(description: "The username of the user")] string $userId,
        IOutput $output,
    ): ExitCode {
        // ...

        return ExitCode::Success;
    }

    #[AsCommand('app:user:delete')]
    public function delete(
        #[Argument(description: "The username of the user")] string $userId,
        IOutput $output,
    ): ExitCode {
        // ...

        return ExitCode::Success;
    }

}

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI (the port of some of the files commands)

@CarlSchwan CarlSchwan self-assigned this Aug 5, 2026
@CarlSchwan
CarlSchwan requested a review from a team as a code owner August 5, 2026 14:12
@CarlSchwan CarlSchwan added 3. to review Waiting for reviews technical debt 🧱 🤔🚀 labels Aug 5, 2026
@CarlSchwan
CarlSchwan requested review from Altahrim, come-nc, leftybournes and nfebe and removed request for a team August 5, 2026 14:12
@CarlSchwan CarlSchwan changed the title Carl/ocp console Command API in OCP Aug 5, 2026
@CarlSchwan
CarlSchwan force-pushed the carl/ocp-console branch 3 times, most recently from 01f9170 to 26fa843 Compare August 6, 2026 08:25
Comment thread apps/files/lib/Command/Mount/ListMounts.php Outdated
Comment thread apps/files/lib/Command/Mount/Refresh.php Outdated
@come-nc

come-nc commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

I think I like the idea.

@CarlSchwan
CarlSchwan force-pushed the carl/ocp-console branch 2 times, most recently from 5af75a7 to 3590a4e Compare August 10, 2026 11:43
@susnux susnux added this to the Nextcloud 35 milestone Aug 10, 2026
Comment thread lib/public/Console/IQuestionHelper.php Outdated
@CarlSchwan
CarlSchwan enabled auto-merge August 11, 2026 08:27
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
The API is inspired by modern command registration in Symfony/Console.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Make sure it is somewhat feature complete with the API used in Base.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Allow to change output depending on the verbosity set by the user.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Allow to ask questions and display a progress bar.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Instead use ask methods from IInput

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Now that we have all the required APIs

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
@CarlSchwan
CarlSchwan merged commit db39397 into master Aug 11, 2026
216 checks passed
@CarlSchwan
CarlSchwan deleted the carl/ocp-console branch August 11, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted technical debt 🧱 🤔🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants