How do I create a command for my app?

Hi everyone :slight_smile:

I would like to create a command for my app and I searched in the official developer documentation and I found nothing on this subject :point_right: Search — Nextcloud latest Developer Manual latest documentation

So, I looked in these repositories :

  1. groupfolders/FolderCommand.php at master · nextcloud/groupfolders · GitHub
  2. circles/CirclesRemote.php at stable25 · nextcloud/circles · GitHub
  3. spreed/ListCommand.php at master · nextcloud/spreed · GitHub

And I saw you use the private API OC\Core\Command\Base.

As a community developer, I cannot use this API.

How do I create a command with a public API ? Do I have to use this private API ?

Thanks in advance :pray:

I’m guessing there’s something extra in OC\Core\Command\Base that’s not been published to the public API, but that’s definitely not normal.

Here is an example of a command using only the public API:

That’s exactly what I thought…

May be for the community, we have to use Symfony\Component\Console\Command\Command ?

May be I will ask the chat directly :thinking:

Thanks @tcit for your answer :slight_smile:

Yes, there’s not much added value to inherit the Base class anyway:

1 Like

Do you need any special functions from your command? I found another app that uses only the public API: server/info.xml at 38aaab3fbf68db0b0b5da14fb17a8bf1dfee5f5d · nextcloud/server · GitHub

Does this help you?

1 Like

Hi @tcit and @christianlupus :slight_smile:

I’m sorry for the delay in replying :pray:

I paused this task because I worked on another one.

I will test on my project later ^^

Thank you for your help :pray: