Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI Commands #779

Merged
merged 89 commits into from
Sep 12, 2024
Merged

Add CLI Commands #779

merged 89 commits into from
Sep 12, 2024

Conversation

mwinkens
Copy link
Contributor

@mwinkens mwinkens commented Mar 26, 2024

This PR adds CLI commands for announcing, deleting and viewing announcements:

announcementcenter:announce [--activities] [--notifications] [--emails] [--comments] [-s|--schedule-time [SCHEDULE-TIME]] [-d|--delete-time [DELETE-TIME]] [-g|--group [GROUP]] [--] <user> <subject> <message>

announcementcenter:delete <id>

announcementcenter:list [<limit>]

Help:

CLICK ME

Announce:

$php occ announcementcenter:announce --help
Description:
  Create an announcement

Usage:
  announcementcenter:announce [options] [--] <user> <subject> <message>

Arguments:
  user                                 User who creates the announcement
  subject                              User for whom the addressbook will be created
  message                              message of the announcement (supports markdown)

Options:
      --activities                     Get notified over activities
      --notifications                  Get notified over nextclouds notifications
      --emails                         Notify users over email
      --comments                       Allow comments
  -s, --schedule-time[=SCHEDULE-TIME]  Publishing time of the announcement (see php strtotime)
  -d, --delete-time[=DELETE-TIME]      Deletion time of the announcement (see php strtotime)
  -g, --group[=GROUP]                  group to set send announcement to (default "everyone", multiple allowed) [default: ["everyone"]] (multiple values allowed)
  -h, --help                           Display help for the given command. When no command is given display help for the list command
  -q, --quiet                          Do not output any message
  -V, --version                        Display this application version
      --ansi|--no-ansi                 Force (or disable --no-ansi) ANSI output
  -n, --no-interaction                 Do not ask any interactive question
      --no-warnings                    Skip global warnings, show command output only
  -v|vv|vvv, --verbose                 Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

List

$php occ announcementcenter:list --help
Description:
  List all announcements

Usage:
  announcementcenter:list [<limit>]

Arguments:
  limit                 Maximal number of announcements listed [default: 10]

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --no-warnings     Skip global warnings, show command output only
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Delete

php occ announcementcenter:delete --help
Description:
  Delete an announcement by id

Usage:
  announcementcenter:delete <id>

Arguments:
  id                    Id of announcement to delete

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --no-warnings     Skip global warnings, show command output only
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Examples:

CLICK ME

Announce:

Minimal

Minimal, you need at least one announcement option:

php occ announcementcenter:announce nextcloud27 'a test' 'a test message'

Announces as user nextcloud27 a message ('a test message') with a subject ('a test').
Default group is everyone, so this announcement reaches everyone. However this didn't use any notification type, like --emails and is just visible in the announcement app

Groups

You can specify multiple groups with --group or -g:

php occ announcementcenter:announce nextcloud27 'a test' 'a test message' --emails --group group1 --group group2

This example only announces to users with group group1 and group2 and sends each user in the group an email

Scheduling/Deletion

You can set the scheduled announcement time with --schedule-time <time>, while the time can be a unix timestamp or any string that can be interpreted by strtotime

Unix-timestamp:

php occ announcementcenter:announce nextcloud27 'a test' 'a test message' --emails --schedule-time 1711443260

String:
Tomorrow:

php occ announcementcenter:announce nextcloud27 'a test' 'a test message' --emails --schedule-time tomorrow

Friday:

php occ announcementcenter:announce nextcloud27 'a test' 'a test message' --emails --schedule-time friday

16:45

php occ announcementcenter:announce nextcloud27 'a test' 'a test message' --emails --schedule-time 16:45

delete-time is similar

List

$php occ announcementcenter:list
ID  |Subject                 |Message                                           
----|------------------------|--------------------------------------------------
33  |testin a bigger subje...|test                                              
25  |test9                   |test9                                             
24  |Your Subject            |Your Plain Body                                   
23  |test8                   |test8                                             
21  |test6                   |test6                                             
20  |test5                   |test5                                             
19  |test4                   |test4                                             
18  |test3                   |lorem ipsum I don't speak latin                   
17  |test2                   |testm    

You can specify the output limit, default is 10:

$php occ announcementcenter:list 3
ID  |Subject                 |Message                                           
----|------------------------|--------------------------------------------------
33  |testin a bigger subje...|test                                              
25  |test9                   |test9                                             
24  |Your Subject            |Your Plain Body                                   
And more ...

Delete

Delete announcement with ID 33:

$php occ announcementcenter:delete 33
Successfully deleted #33

Roadmap

  • tests!

based on #767 (merged)
closes #147

mwinkens added 30 commits March 18, 2024 09:43
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
…is added

Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
…Options are missing

Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
…abase id

Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
@mwinkens mwinkens marked this pull request as ready for review July 29, 2024 12:04
@mwinkens mwinkens requested a review from nickvergessen as a code owner July 29, 2024 12:04
@mwinkens
Copy link
Contributor Author

@nickvergessen this is also ready for review and if you want we can integrate this into the next update! ~400 lines of this ~800 lines PR are just unit tests, so this shouldn't take too much effort. Also this PR doesn't have a frontend 🎉

@@ -28,6 +28,11 @@
<referencedClass name="Doctrine\DBAL\Types\Types" />
<referencedClass name="OC" />
<referencedClass name="OCA\Guests\UserBackend" />
<referencedClass name="Symfony\Component\Console\Command\Command" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of this thirdparty access. Symfony version is not the same across all supported versions.
Also by ignoring it in psalm, CI will not detect if there is an issue. But yeah we don't have a better option atm.

lib/Command/Announce.php Outdated Show resolved Hide resolved
lib/Command/Announce.php Outdated Show resolved Hide resolved
lib/Command/Announce.php Outdated Show resolved Hide resolved
lib/Command/Announce.php Outdated Show resolved Hide resolved
lib/Command/Announce.php Outdated Show resolved Hide resolved
lib/Command/Announce.php Outdated Show resolved Hide resolved
lib/Command/AnnouncementDelete.php Outdated Show resolved Hide resolved
lib/Command/AnnouncementList.php Outdated Show resolved Hide resolved
mwinkens and others added 8 commits July 29, 2024 14:33
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Signed-off-by: mwinkens <104770531+mwinkens@users.noreply.github.com>
Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Signed-off-by: mwinkens <104770531+mwinkens@users.noreply.github.com>
Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Signed-off-by: mwinkens <104770531+mwinkens@users.noreply.github.com>
Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Signed-off-by: mwinkens <104770531+mwinkens@users.noreply.github.com>
Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Signed-off-by: mwinkens <104770531+mwinkens@users.noreply.github.com>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
mwinkens added 2 commits July 29, 2024 15:55
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
@mwinkens
Copy link
Contributor Author

@nickvergessen ready for review again 🎉

This allows to add announcements without a notification type, which the API allows, these notifications will still appear in the notification app listed

Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Signed-off-by: mwinkens <104770531+mwinkens@users.noreply.github.com>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
Signed-off-by: Marvin Winkens <m.winkens@fz-juelich.de>
@nickvergessen nickvergessen merged commit 911153c into nextcloud:main Sep 12, 2024
43 checks passed
@pierreozoux
Copy link
Member

Really nice!

Thanks @nickvergessen and @mwinkens \o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate Announcement from CLI/OCC
5 participants