public static void ValidateRequiredParameters(CommandTree?tree) { var node = tree?.GetRootCommand(); while (node != null) { foreach (var parameter in node.Unmapped) { if (parameter.Required) { switch (parameter) { case CommandArgument argument: throw CommandRuntimeException.MissingRequiredArgument(node, argument); } } } node = node.Next; } }
private static void ValidateRequiredParameters(CommandTree tree) { var node = tree.GetRootCommand(); while (node != null) { foreach (var parameter in node.Unmapped) { if (parameter.Required) { switch (parameter) { case CommandOption option: throw new CommandAppException($"Command '{node.Command.Name}' is missing required option '{option.GetOptionName()}'."); case CommandArgument argument: throw new CommandAppException($"Command '{node.Command.Name}' is missing required argument '{argument.Value}'."); } } } node = node.Next; } }