diff --git a/node/api/src/main/java/eu/cloudnetservice/node/command/annotation/EnableConfirmSkipFlag.java b/node/api/src/main/java/eu/cloudnetservice/node/command/annotation/EnableConfirmSkipFlag.java new file mode 100644 index 0000000000..a898de2f6e --- /dev/null +++ b/node/api/src/main/java/eu/cloudnetservice/node/command/annotation/EnableConfirmSkipFlag.java @@ -0,0 +1,50 @@ +/* + * Copyright 2019-2024 CloudNetService team & contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package eu.cloudnetservice.node.command.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import lombok.NonNull; + +/** + * This annotation allows users to skip the required confirmation + * {@link org.incendo.cloud.processors.confirmation.annotation.Confirmation} of a command. When this annotation is + * applied to a method a flag is implicitly appended to the command which can be used to skip the confirmation. + *
+ * The annotations value is used as the flag name, which defaults to {@code confirm}. + * + * @see org.incendo.cloud.processors.confirmation.annotation.Confirmation + * @since 4.0 + */ +@Documented +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface EnableConfirmSkipFlag { + + /** + * The value of this annotation is used as the flag name to skip the confirmation. Should not include the leading + * dashes. + *
+ * Defaults to {@code confirm}, allowing users to skip the confirmation by appending {@code --confirm}.
+ *
+ * @return the flag name that allows skipping.
+ */
+ @NonNull String value() default "confirm";
+}
diff --git a/node/impl/src/main/java/eu/cloudnetservice/node/impl/command/defaults/DefaultCommandProvider.java b/node/impl/src/main/java/eu/cloudnetservice/node/impl/command/defaults/DefaultCommandProvider.java
index 629f37135f..dcd1da11e7 100644
--- a/node/impl/src/main/java/eu/cloudnetservice/node/impl/command/defaults/DefaultCommandProvider.java
+++ b/node/impl/src/main/java/eu/cloudnetservice/node/impl/command/defaults/DefaultCommandProvider.java
@@ -29,6 +29,7 @@
import eu.cloudnetservice.node.command.annotation.CommandAlias;
import eu.cloudnetservice.node.command.annotation.Description;
import eu.cloudnetservice.node.command.annotation.Documentation;
+import eu.cloudnetservice.node.command.annotation.EnableConfirmSkipFlag;
import eu.cloudnetservice.node.command.source.CommandSource;
import eu.cloudnetservice.node.impl.command.exception.CommandExceptionHandler;
import eu.cloudnetservice.node.impl.command.sub.ClearCommand;
@@ -70,6 +71,7 @@
import org.incendo.cloud.annotations.AnnotationParser;
import org.incendo.cloud.key.CloudKey;
import org.incendo.cloud.meta.CommandMeta;
+import org.incendo.cloud.parser.flag.CommandFlag;
import org.incendo.cloud.processors.cache.CaffeineCache;
import org.incendo.cloud.processors.confirmation.ConfirmationConfiguration;
import org.incendo.cloud.processors.confirmation.ConfirmationManager;
@@ -88,6 +90,7 @@ public final class DefaultCommandProvider implements CommandProvider {
});
private static final CloudKey