Skip to content

API proposal: AcceptOnlyFromAmong for enum #1960

Open

Description

@KalleOlaviNiemitalo
 namespace System.CommandLine {
     public partial class ArgumentValidation {
+        public static Argument<TEnum> AcceptOnlyFromAmong<TEnum>(
+            this Argument<TEnum> argument,
+            params TEnum[] values)
+            where TEnum: struct, System.Enum;
     }
 
     public partial class OptionValidation {
+        public static Option<TEnum> AcceptOnlyFromAmong<TEnum>(
+            this Option<TEnum> option,
+            params TEnum[] values)
+            where TEnum: struct, System.Enum;
     }
 }

Same behaviour as in Argument.AcceptOnlyFromAmong(params string[]) and Option.AcceptOnlyFromAmong(params string[]), except:

Inspired by #1959 (comment)

Activity

  1. added
    enhancement
    on Nov 11, 2022
  2. changed the title [-]API proposal: AcceptOnlyFromAmong enum[/-] [+]API proposal: AcceptOnlyFromAmong for enum[/+] on Nov 11, 2022
  3. KalleOlaviNiemitalo commented on Nov 14, 2022

    @KalleOlaviNiemitalo
    Author

    Could add the same for Option<TEnum?> as well.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-APIenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions