+ .choices("enabled", "enabled-with-approval", "disabled");
+
+ subparser.addArgument("--set-permission-add-member")
+ .help("Set permission to add new group members")
+ .choices("every-member", "only-admins");
+ subparser.addArgument("--set-permission-edit-details")
+ .help("Set permission to edit group details")
+ .choices("every-member", "only-admins");
+ subparser.addArgument("--set-permission-send-messages")
+ .help("Set permission to send messages")
+ .choices("every-member", "only-admins");
+
+ subparser.addArgument("-e", "--expiration").type(int.class).help("Set expiration time of messages (seconds)");
+ }
+
+ GroupLinkState getGroupLinkState(String value) throws UserErrorException {
+ if (value == null) {
+ return null;
+ }
+ switch (value) {
+ case "enabled":
+ return GroupLinkState.ENABLED;
+ case "enabled-with-approval":
+ case "enabledWithApproval":
+ return GroupLinkState.ENABLED_WITH_APPROVAL;
+ case "disabled":
+ return GroupLinkState.DISABLED;
+ default:
+ throw new UserErrorException("Invalid group link state: " + value);
+ }
+ }
+
+ GroupPermission getGroupPermission(String value) throws UserErrorException {
+ if (value == null) {
+ return null;
+ }
+ switch (value) {
+ case "every-member":
+ case "everyMember":
+ return GroupPermission.EVERY_MEMBER;
+ case "only-admins":
+ case "onlyAdmins":
+ return GroupPermission.ONLY_ADMINS;
+ default:
+ throw new UserErrorException("Invalid group permission: " + value);
+ }