예제 #1
0
        public static OptTableBuilder AddUnknown(this OptTableBuilder builder, OptSpecifier id)
        {
            if (!id.IsValid)
            {
                throw new ArgumentException("Invalid id");
            }

            builder.Add(new UnknownOption(id.Id));
            return(builder);
        }
예제 #2
0
파일: GroupOption.cs 프로젝트: gix/noption
        public static OptTableBuilder AddGroup(
            this OptTableBuilder builder,
            OptSpecifier id,
            string name,
            string helpText = null,
            string metaVar  = null)
        {
            var option = new GroupOption(
                id.Id,
                name,
                helpText: helpText,
                metaVar: metaVar);

            builder.Add(option);
            return(builder);
        }
예제 #3
0
        public static OptTableBuilder AddSeparate(
            this OptTableBuilder builder,
            OptSpecifier id,
            IReadOnlyList <string> prefixes,
            string name,
            string helpText      = null,
            string metaVar       = null,
            OptSpecifier?aliasId = null,
            OptSpecifier?groupId = null)
        {
            if (!id.IsValid)
            {
                throw new ArgumentException("Invalid id");
            }
            if (prefixes == null)
            {
                throw new ArgumentNullException(nameof(prefixes));
            }
            if (prefixes.Count == 0)
            {
                throw new ArgumentException("Contract violated: prefixes.Count != 0");
            }
            if (prefixes.Any(string.IsNullOrWhiteSpace))
            {
                throw new ArgumentException("Contract violated: !string.IsNullOrWhiteSpace(prefix)");
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var option = new SeparateOption(
                id.Id,
                prefixes,
                name,
                helpText: helpText,
                metaVar: metaVar,
                aliasId: aliasId,
                groupId: groupId);

            builder.Add(option);
            return(builder);
        }
예제 #4
0
        public static OptTableBuilder AddRemainingArgs(
            this OptTableBuilder builder,
            OptSpecifier id,
            IReadOnlyList <string> prefixes,
            string name,
            string helpText      = null,
            string metaVar       = null,
            OptSpecifier?aliasId = null,
            OptSpecifier?groupId = null)
        {
            var option = new RemainingArgsOption(
                id.Id,
                prefixes,
                name,
                helpText: helpText,
                metaVar: metaVar,
                aliasId: aliasId,
                groupId: groupId);

            builder.Add(option);
            return(builder);
        }
예제 #5
0
        public static OptTableBuilder AddJoinedOrSeparate(
            this OptTableBuilder builder,
            OptSpecifier id,
            string prefix,
            string name,
            string helpText      = null,
            string metaVar       = null,
            OptSpecifier?aliasId = null,
            OptSpecifier?groupId = null)
        {
            var option = new JoinedOrSeparateOption(
                id.Id,
                prefix,
                name,
                helpText: helpText,
                metaVar: metaVar,
                aliasId: aliasId,
                groupId: groupId);

            builder.Add(option);
            return(builder);
        }
예제 #6
0
파일: JoinedOption.cs 프로젝트: gix/noption
        public static OptTableBuilder AddJoined(
            this OptTableBuilder builder,
            OptSpecifier id,
            string prefix,
            string name,
            string helpText      = null,
            string metaVar       = null,
            OptSpecifier?aliasId = null,
            OptSpecifier?groupId = null)
        {
            if (!id.IsValid)
            {
                throw new ArgumentException("Invalid id");
            }
            if (prefix == null)
            {
                throw new ArgumentNullException(nameof(prefix));
            }
            if (string.IsNullOrWhiteSpace(prefix))
            {
                throw new ArgumentException("Contract violated: !string.IsNullOrWhiteSpace(prefix)");
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var option = new JoinedOption(
                id.Id,
                prefix,
                name,
                helpText: helpText,
                metaVar: metaVar,
                aliasId: aliasId,
                groupId: groupId);

            builder.Add(option);
            return(builder);
        }
예제 #7
0
        public static OptTableBuilder AddMultiArg(
            this OptTableBuilder builder,
            OptSpecifier id,
            IReadOnlyList <string> prefixes,
            string name,
            int argumentCount,
            string helpText      = null,
            string metaVar       = null,
            OptSpecifier?aliasId = null,
            OptSpecifier?groupId = null)
        {
            var option = new MultiArgOption(
                id.Id,
                prefixes,
                name,
                argumentCount,
                helpText: helpText,
                metaVar: metaVar,
                aliasId: aliasId,
                groupId: groupId);

            builder.Add(option);
            return(builder);
        }